-
-
Save nesquena/898db22a38747bd9bc19 to your computer and use it in GitHub Desktop.
ViewPager that allows disabling swiping events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LockableViewPager extends ViewPager { | |
private boolean swipeable; | |
public LockableViewPager(Context context) { | |
super(context); | |
} | |
public LockableViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
this.swipeable = true; | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
if (this.swipeable) { | |
return super.onTouchEvent(event); | |
} | |
return false; | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent event) { | |
if (this.swipeable) { | |
return super.onInterceptTouchEvent(event); | |
} | |
return false; | |
} | |
public void setSwipeable(boolean swipeable) { | |
this.swipeable = swipeable; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a ton for the contribution! :*