I’m trying to convert my app to use ViewPager 2, however I’m stuck on converting to FragmentStateAdapter from FragmentStatePagerAdapter. I have
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
2
Answers
Either use
this
as your activity is a FragmentActivity or if you want to fill up part of the screen get a reference to the fragment.Other constructor options are
viewpager -> viewpager2 migration documentation
In order to make it work you can fix using
I had the same migration issue sometime ago and found that creating a custom fragment state adapter way quite flexible and much more readable.