Created
July 10, 2015 02:28
-
-
Save okaybroda/6760983ceb304d0fcdf0 to your computer and use it in GitHub Desktop.
Disable and enable sliding for a ViewPager
This file contains hidden or 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 NonSlidingViewPager extends ViewPager { | |
boolean allowSliding = true; | |
public NonSlidingViewPager(Context context) { | |
super(context); | |
} | |
public NonSlidingViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent event) { | |
return allowSliding && super.onInterceptTouchEvent(event); | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
return allowSliding && super.onTouchEvent(event); | |
} | |
public void setSliding(boolean enabled) { | |
allowSliding = enabled; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment