Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT

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
    )
like image 840
user1114 Avatar asked Mar 20 '26 10:03

user1114


1 Answers

The ViewPager2's FragmentStateAdapter has the same functionality as BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT (this is, in fact, the only type of behavior ViewPager2 supports).

The ViewPager2 migration guide details the exact steps needed to convert to ViewPager2.

like image 96
ianhanniballake Avatar answered Mar 22 '26 02:03

ianhanniballake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!