0

I have an activity containg framelayout, fragment A is hosted with getSupportFragmentManager() in this.

This fragment A hosts two more fragments which has recycler views in it -Fragment A1 and Fragment A2 using FragmentStatePagerAdapter. At this point of time i was able to get Parent Fragment using getSupportFragmentManager() in Fragment A1 and A2.

Click on recycler view item in A1 and A2 results in another Fragment say Fragment B that replaces Fragment A and adds it to backstack.

Now the problem comes here, when i press back button i was able to get the Fragment State A view but getSupportFragmentManager() is returning null for parent fragment in A1 and A2 fragments.

How should this method be used properly?

Raviteja
  • 97
  • 3
  • 16

1 Answers1

1

Use getChildFragmentManager() in viewpager when the viewpager is nested inside a fragment.

adapter = new ViewPagerAdapter(getChildFragmentManager());
Suhaib Roomy
  • 2,501
  • 1
  • 16
  • 22