无法在片段 TextView 中设置文本
Can't set text in fragments TextView
我对 setText()
函数有奇怪的问题。我想在单击特定项目时显示 listview
项目详细信息。我想在 3 个选项卡中显示此详细信息,所以我使用 fragments
。这是其中之一的我的代码。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Intent intent = getActivity().getIntent();
int position = intent.getExtras().getInt("Position");
View rootView = inflater.inflate(R.layout.album_tab1, container, false);
Log.e("Position", String.valueOf(position));
Log.e("Value: ", ParseJSONDetail.overview[position]);
final TextView title = (TextView) rootView.findViewById(R.id.album_title);
final TextView overview = (TextView) rootView.findViewById(R.id.album_overview);
final TextView band = (TextView) rootView.findViewById(R.id.album_band);
final ImageView okladka = (ImageView) rootView.findViewById(R.id.album_okladka);
overview.setText(ParseJSONDetail.overview[position]);
imgload.getInstance().displayImage(ParseJSONDetail.image[position], okladka);
band.setText(ParseJSONDetail.band[position]);
title.setText(ParseJSONDetail.title[position]);
return inflater.inflate(R.layout.album_tab1, container, false);
}
奇怪的是,在日志中我可以显示我想要的数据。
知道这段代码有什么问题吗?
替换
return inflater.inflate(R.layout.album_tab1, container, false);
和
return rootView;
我对 setText()
函数有奇怪的问题。我想在单击特定项目时显示 listview
项目详细信息。我想在 3 个选项卡中显示此详细信息,所以我使用 fragments
。这是其中之一的我的代码。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Intent intent = getActivity().getIntent();
int position = intent.getExtras().getInt("Position");
View rootView = inflater.inflate(R.layout.album_tab1, container, false);
Log.e("Position", String.valueOf(position));
Log.e("Value: ", ParseJSONDetail.overview[position]);
final TextView title = (TextView) rootView.findViewById(R.id.album_title);
final TextView overview = (TextView) rootView.findViewById(R.id.album_overview);
final TextView band = (TextView) rootView.findViewById(R.id.album_band);
final ImageView okladka = (ImageView) rootView.findViewById(R.id.album_okladka);
overview.setText(ParseJSONDetail.overview[position]);
imgload.getInstance().displayImage(ParseJSONDetail.image[position], okladka);
band.setText(ParseJSONDetail.band[position]);
title.setText(ParseJSONDetail.title[position]);
return inflater.inflate(R.layout.album_tab1, container, false);
}
奇怪的是,在日志中我可以显示我想要的数据。 知道这段代码有什么问题吗?
替换
return inflater.inflate(R.layout.album_tab1, container, false);
和
return rootView;