Android – ViewPager empty problem inside nested fragments

When you use ViewPager in Fragment of Navigation Drawer, ViewPager is empty on restarting. How to solve it?

You may have something like this:

FragmentViewPagerAdapter adapter = new FragmentViewPagerAdapter(getActivity().getSupportFragmentManager());

Change that to this:

FragmentViewPagerAdapter adapter = new FragmentViewPagerAdapter(getChildFragmentManager());

That’s it. Now ViewPager is not empty.