标签:smooth creat eth extend 滑动 tor ack etc viewpager
package com.lvshandian.menshen.view;
/**
* Created by zhang on 2016/11/8.
* 创建自定义滑动,禁止滑动的ViewPager
*/
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class MyViewPager extends ViewPager {
//设置是否滑动
private boolean isCanScroll = true;
public MyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MyViewPager(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
//设置是否滑动
public void setCanScroll(boolean isCanScroll) {
this.isCanScroll = isCanScroll;
}
@Override
public boolean onTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
if (isCanScroll) {
return super.onTouchEvent(arg0);
} else {
return false;
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
if (isCanScroll) {
return super.onInterceptTouchEvent(arg0);
} else {
return false;
}
}
@Override
public void setCurrentItem(int item, boolean smoothScroll) {
// TODO Auto-generated method stub
super.setCurrentItem(item, smoothScroll);
}
@Override
public void setCurrentItem(int item) {
// TODO Auto-generated method stub
super.setCurrentItem(item, false);
}
}
标签:smooth creat eth extend 滑动 tor ack etc viewpager
原文地址:http://www.cnblogs.com/huihuizhang/p/6043378.html