I\'m using a ViewPager
together with a FragmentStatePagerAdapter
to host three different fragments:
The easiest and the most concise way. If all your fragments in ViewPager
are of different classes you may retrieve and distinguish them as following:
public class MyActivity extends Activity
{
@Override
public void onAttachFragment(Fragment fragment) {
super.onAttachFragment(fragment);
if (fragment.getClass() == MyFragment.class) {
mMyFragment = (MyFragment) fragment;
}
}
}