ViewPager禁止滑动

定义一个类继承ViewPager,覆盖onTouchEvent和onInterceptTouchEvent方法,return false

import android.content.Context;

import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;


public class MyViewPager extends ViewPager{


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
}

@Override
public boolean onTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}

}

你可能感兴趣的:(ViewPager禁止滑动)