In bottom navigation with three tabs (Home, Dashboard, Notifications). Each bottom navigation tab is a fragment. The first tab ie. Home fragment contains another top navigat
Try use getChildFragmentManager()
instance of getSupportFragmentManager()
.
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.