Android- skipping a page in View pager depending on certain condition [closed]

好久不见. 提交于 2019-12-23 16:43:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!