10

When I try to re-use a Viewpager2 FragmentStateAdapter, I get this error. I already tried to set the adapter to null in onDestroyView but this does not help.

This occurs because I am using the Jetpack Navigation libarary. When I navigate away from a fragment, the View is destroyed. When I navigate back, it is recreated and I need to set the adapter again. When I do, the adapter already has fragments inside, which throws the mentioned error during restoreState().

sunilson
  • 1,449
  • 15
  • 31

0 Answers0