Skipping a specific page in the ViewPager
I have a View pager with a list of fragments on its adapter. This is the scenario I want to achieve:
Suppose we have 4 fragments: Fragment1 FRAGMENT2 Fragment3 Fragment4
When I'm in Fragment4, scrolling back should take me to Fragment2. This will be the workflow:
Fragment1 → Fragment2 → Fragment3 → Fragment4
Fragment1 <- Fragment2 <- Fragment4
I want to skip Fragment3 when scrolling from Fragment4.
Any help is greatly appreciated. Thank you very much.
source to share
Take a look at this Android-WizardPager project by Roman Nurik. It uses a method recalculateCutOffPage
in MainActivity
to lock pages in the ViewPager and add / remove them dynamically. I think you can use it as a base and extend its functionality to be "swipe-back" compatible with your "dynamic" ViewPager as well.
source to share