Currently, with a FragmentActivity
, I toggle among 2 type of Fragments using the following code.
private void toggle() {
Fragment oldFragmen
Global working tested solution.
getSupportFragmentManager()
keeps the null reference some times and View pager does not create new fragment instance.Since it finds reference to same fragment. So to over come this use getChildFragmentManager()
solves problem in simple way.
Don't
new PagerAdapter(getSupportFragmentManager(), fragments);
Do
new PagerAdapter(getChildFragmentManager() , fragments);