Multiple Tab fragments inside bottom navigation fragment
Actually, it is a common mistake - you're using FragmentManager
of your Activity
inside the fragment, but since this fragment contains another child fragments you have to use FragmentManager
of the fragment itself. So the fix is simple - you just have to change getActivity().getSupportFragmentManager()
to getChildFragmentManager()
inside your fragments, so the code will be:
private void setupViewPager(ViewPager viewPager) {
TabViewPagerAdapter adapter = new TabViewPagerAdapter(getChildFragmentManager());
...
...
viewPager.setAdapter(adapter);
}
And this should work as expected.