Friday, 27 September 2013

How to make last page in ViewPager completely inaccessible

How to make last page in ViewPager completely inaccessible

In an App that I am working on, I implement a ViewPager. At some point, I
want to make the last page in the ViewPager completely inaccessible. To do
that I set up the getCount() method in my SectionsPagerAdapter like this:
@Override
public int getCount() {
return mPageCount;
}
When I want to make the last page inaccessible, I just subtract 1 from
mPageCount (which is a global variable) and the user can't access it
anymore. This works but the problem is that the user still can see the
last page if he flings the ViewPager in the second-to-last page. The
ViewPager will bounce back, so he can't stay at the last page, but he can
see it. Also there is no edge effect. Basically my question is: "How do I
remove the last page from the ViewPager such that it is COMPLETELY gone
(it should appear as if that is the end of the ViewPager)?"

No comments:

Post a Comment