Created
October 17, 2017 08:35
-
-
Save s1ntoneli/0aafe90d4c5b4ff7eeaa41bc72c80b43 to your computer and use it in GitHub Desktop.
禁用翻页的 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 CustomViewPager extends ViewPager { | |
| private boolean isPagingEnabled = true; | |
| public CustomViewPager(Context context) { | |
| super(context); | |
| } | |
| public CustomViewPager(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } | |
| @Override | |
| public boolean onTouchEvent(MotionEvent event) { | |
| return this.isPagingEnabled && super.onTouchEvent(event); | |
| } | |
| @Override | |
| public boolean onInterceptTouchEvent(MotionEvent event) { | |
| return this.isPagingEnabled && super.onInterceptTouchEvent(event); | |
| } | |
| public void setPagingEnabled(boolean b) { | |
| this.isPagingEnabled = b; | |
| }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment