I'm an Android application that have one activity that have a ViewPager with 4 Fragments.
Now I'm building a OnPageChangeListener and in the method onPageSelected I want to get the current fragment that the user can see. So I have used this code:
public void onPageSelected(int position) {
Fragment currFragment = null;
FragmentManager fm = getSupportFragmentManager();
List<Fragment> fragments = fm.getFragments();
//TO DO
}
but the list of Fragment contains only 3 Fragment instead of 4. Why ?
How can I get the current Fragment ?