禁用ViewPager的滑动事件

public class NoScrollViewPager extends ViewPager {

    private boolean noScroll = false;

    public NoScrollViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
} public NoScrollViewPager(Context context) {
super(context);
} public void setNoScroll(boolean noScroll) {
this.noScroll = noScroll;
} @Override
public void scrollTo(int x, int y) {
super.scrollTo(x, y);
} @Override
public boolean onTouchEvent(MotionEvent arg0) {
if (noScroll)
return false;
else
return super.onTouchEvent(arg0);
} @Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
if (noScroll)
return false;
else
return super.onInterceptTouchEvent(arg0);
} @Override
public void setCurrentItem(int item, boolean smoothScroll) {
super.setCurrentItem(item, smoothScroll);
} @Override
public void setCurrentItem(int item) {
super.setCurrentItem(item);
} }
setNoScroll方法设置是否禁用滑动

  

上一篇:hdu 4504 威威猫系列故事——篮球梦_简单dp


下一篇:O(logn)二叉树中的意义----高性能(四)