Answer
While working with Viewpager with FragmentPagerAdapter i have noticed this deprecated messages. i have created FragmentPagerAdapter class like below
class MyViewPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager)
|
To overcome the issue i have modified FragmentPagerAdapter() constructor
Solution 1: By replacing the above code with below code we can resolve the error
class MyViewPagerAdapter(manager:FragmentManager) : FragmentPagerAdapter(manager, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
|
Solution 2:
![]() |
By switch from Viewpager to ViewPager2 and create adapter by FragmentStateAdapter or FragmentStatePagerAdapter instead
