AndreiBogdan
AndreiBogdan

Reputation: 11164

Stop ViewPager from scrolling to see the last page

I have a ViewPager which i populate with 4 items. I need it to be scrollable until the 3rd item (inclusive) but when the user tries to move to the 4th one it should just not let him. When he validates the 3 pages, only then i need to allow him to move to the 4th.

Don't ask why, it's complicated, but I can't instantiate and set the 4th page to the adapter only AFTER the first 3 are validated. That would solve my problem, indeed. I need to have it already available in the list.

Any suggestions?

I tried playing around with onPageScrolled() to see if I can stop it from moving forward even a pixel, but I wasn't able to figure it out.

Upvotes: 0

Views: 340

Answers (1)

Varun Jain
Varun Jain

Reputation: 171

@Override
public int getCount() {
      if(!isAccess) {
        return 3;
      } else {
        return 4;
      }
    }

Upvotes: 1

Related Questions