无法在片段TextView中设置文本

时间:2015-12-29 11:20:47

标签: android android-fragments settext

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);
}

奇怪的是,在Log中我可以显示我想要的数据。 任何想法这个代码有什么问题?

1 个答案:

答案 0 :(得分:1)

替换

return inflater.inflate(R.layout.album_tab1, container, false);

return rootView;
相关问题