androidx.fragment.app.FragmentStatePagerAdapter is deprecated and developers are urged to switch to androidx.viewpager2.adapter.FragmentStateAdapter
How can we get the same functionality with FragmentStateAdapter that BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT provided?
This code below is now deprecated
FragmentStatePagerAdapter(
fragmentManager,
BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
)
The ViewPager2's
FragmentStateAdapterhas the same functionality asBEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT(this is, in fact, the only type of behaviorViewPager2supports).The
ViewPager2migration guide details the exact steps needed to convert toViewPager2.