Reputation: 93
Since few days I tried to disable the SWIPE. I read so many conversations at stackoverflow, but all this didn't work or was too old. I have a next Button
. Only with the next Button
the User should Come to the next Layout
without swiping.
So have anybody a solution to disable swiping?
Upvotes: 1
Views: 9486
Reputation: 206
In order to get something like this working, you will need to create your own subclass of ViewPager.
It should have a new field: e.g.
private boolean swipeEnabled;
You will also need to override onInterceptTouchEvent
and onTouchEvent
and check if the user has currently enabled / disabled the ViewPager
.
e.g.
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return isEnabled && super.onInterceptTouchEvent(event);
}
Then in your code where you are hosting your ViewPager
you should have an enable and disable method that change the value of that new field based on your needs.
Make sure in your xml layout you use this new class rather than the default ViewPager class.
Upvotes: 1