I\'m using a ViewPager
together with a FragmentStatePagerAdapter
to host three different fragments:
in TabLayout there are multiple tab for Fragment. you can find the fragment by Tag using the index of the fragment.
For ex. the index for Fragment1 is 0, so in findFragmentByTag()
method, pass the tag for the Viewpager.after using fragmentTransaction you can add,replace the fragment.
String tag = "android:switcher:" + R.id.viewPager + ":" + 0;
Fragment1 f = (Fragment1) getSupportFragmentManager().findFragmentByTag(tag);