Last active
December 15, 2015 03:19
-
-
Save stephenparish/5193561 to your computer and use it in GitHub Desktop.
An easy to enable or disable view pager for Android
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 StoppableViewPager extends ViewPager { | |
private boolean mEnabled; | |
public StoppableViewPager(Context context) { | |
super(context); | |
mEnabled = true; | |
} | |
public StoppableViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
mEnabled = true; | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
return mEnabled ? super.onTouchEvent(event) : false; | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent event) { | |
return mEnabled ? super.onInterceptTouchEvent(event) : false; | |
} | |
public void setPagingEnabled(boolean enabled) { | |
mEnabled = enabled; | |
} | |
public boolean isPagingEnabled() { | |
return mEnabled; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment