I\'m using a ViewPager
together with a FragmentStatePagerAdapter
to host three different fragments:
Must extends FragmentPagerAdapter
into your ViewPager adapter class.
If you use FragmentStatePagerAdapter
then you will not able to find your Fragment
by its ID
public static String makeFragmentName(int viewPagerId, int index) {
return "android:switcher:" + viewPagerId + ":" + index;
}
How to use this method :-
Fragment mFragment = ((FragmentActivity) getContext()).getSupportFragmentManager().findFragmentByTag(
AppMethodUtils.makeFragmentName(mViewPager.getId(), i)
);
InterestViewFragment newFragment = (InterestViewFragment) mFragment;