写一个viewpager继承ViewPager 通过复写方法判断
现在也是在网上找的解决方案. 这在尝试这个方案的可行性
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent ( MotionEvent event ) {
if (getAdapter() == null || getAdapter().getCount() == 0) {
return false;
}
return super.onInterceptTouchEvent(event);
}
@Override
public boolean onTouchEvent ( MotionEvent ev ) {
if (getAdapter() == null || getAdapter().getCount() == 0) {
return false;
}
return super.onTouchEvent(ev);
}}
网友评论