首页 > 学院 > 开发设计 > 正文

转:ViewPager禁止滑动

2019-11-09 18:22:31
字体:
来源:转载
供稿:网友

原文出自 http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0102/2254.html

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;    }}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表