Control which directions the ViewPager can be scrolled, dynamically with UI feedback

后端 未结 5 507
既然无缘
既然无缘 2020-12-13 22:40

I\'m working on an app which uses many pages to swipe through, however at some pages I would like to be able to prevent scrolling to the next page until they\'ve selected so

5条回答
  •  再見小時候
    2020-12-13 23:13

    I don't think extending ViewPager is needed. What you need to do is to modify the list of pages provided to the PagerAdapter on the fly. Meaning that, you check if a certain page is marked "completed" and only then add the next page to the list. That's how ViewPager works.

    Take a look at Roman Nurik's wizard-pager implementation. In MainActivity there is a method called recalculateCutOffPage which does what I said.

提交回复
热议问题