标签:地方 oid override item 调用 his bool slide viewpager
import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; public class ViewPagerNoSlide extends ViewPager { private boolean isCanScroll = false; public ViewPagerNoSlide(Context context) { super(context); } public ViewPagerNoSlide(Context context, AttributeSet attrs) { super(context, attrs); } public void setScanScroll(boolean isCanScroll) { this.isCanScroll = isCanScroll; } @Override public void scrollTo(int x, int y) { super.scrollTo(x, y); } @Override public boolean onTouchEvent(MotionEvent arg0) { if (isCanScroll) { return super.onTouchEvent(arg0); } else { return false; } } @Override public void setCurrentItem(int item, boolean smoothScroll) { super.setCurrentItem(item, smoothScroll); } @Override public void setCurrentItem(int item) { super.setCurrentItem(item); } @Override public boolean onInterceptTouchEvent(MotionEvent arg0) { if (isCanScroll) { return super.onInterceptTouchEvent(arg0); } else { return false; } } }
然后在需要的地方调用
setScanScroll(false);
标签:地方 oid override item 调用 his bool slide viewpager
原文地址:http://www.cnblogs.com/anni-qianqian/p/6478293.html