Reputation:
My project consists of a fragment which has three tabs and when I click on tab each tab opens a new fragment.First time when i open the fragment all three tabs opens their respective fragment fine but then when I go to some other fragment and return back to these fragment then one of the three tabs show blank fragment and sometimes two of three tabs show blank fragment.Then if I return to the main activity and then open these fragments again for first time all three tabs opens their respective fragment fine.Why does this happen?
Upvotes: 5
Views: 2308
Reputation: 3458
Instead of using (Replace your below line to)
mAdapter = new MyAdapter(getFragmentManager(), yourDataList); // OR
mAdapter = new MyAdapter(getActivity().getFragmentManager(), yourDataList);
You should use (this line)
mAdapter = new MyAdapter(getChildFragmentManager(), yourDataList);
Upvotes: 1
Reputation: 588
Change
mAdapter = new TabsPagerAdapter(myContext.getSupportFragmentManager());
To
mAdapter = new TabsPagerAdapter(getChildFragmentManager());
Upvotes: 14