I have Navigation Drawer
in which there is one fragment for the Tab Viewer
. In tabviewer, I am using ViewPager
which also in the Fragment
.
The code for ViewPager
is
viewPager = (ViewPager) rootView.findViewById(R.id.pager);
viewPager.setAdapter(new TabsPagerAdapter(((FragmentActivity)getActivity()).getSupportFragmentManager()));
PagerSlidingTabStrip tabsStrip = (PagerSlidingTabStrip) rootView.findViewById(R.id.tabs);
tabsStrip.setViewPager(viewPager);
The tabs is coming in the first click in the navigation drawer with its content but for the second time the only title of tabs is coming without its layout. Layout is not coming and swipe is also not working between different tabs? Why its working for the first time but not for the rest? I am attaching the images for two different click on same navigation drawer fragment. This is first click so the layout is coming perfectly.
This in 2nd attempt to click on the same fragment but only background is coming without any layout content.
Help to get rid of this problem.
use
getChildFragmentManager()
instead of
((FragmentActivity)getActivity()).getSupportFragmentManager()
I used getFragementManager(). So I was able to reload fragments used in tabs. Now, I used getChildFragmentManager(). It works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With