Search code examples
androidandroid-fragmentssettext

Can't set text in fragments TextView


I have strange problem with setText() function. I want to display listview item details when i click on specific item. I want to display this details in 3 tabs so I use fragments. This is my code from one of them.

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

Strange is that in Log i can display this data what i want. Any ideas what's wrong with this code?


Solution

  • replace

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

    with

    return rootView;