问题
How to skip a page in a ViewPager depending on certain condition , swiping forward or backward , knowing that i don't know the the position of these pages .
回答1:
Yes you can. Normally what happens is that you will create a ViewPager
and set an adapter to it. This adapter has the getItem(position)
method. You override this method and for each position you will spit out a Fragment
. This is the place where you need to check your condition and send out different Fragment
.
However if you are going to reduce the number of items, you also need to adapt the getCount()
to suit your needs.
More info here:
Changing Count of ViewPager
Update ViewPager dynamically?
来源:https://stackoverflow.com/questions/33238797/android-skipping-a-page-in-view-pager-depending-on-certain-condition