我试图禁止我的 ViewPager 在选项卡之间滚动。我有以下情况:
public class MyClass extends ViewPager implements ViewPager.OnPageChangeListener, OnTouchListener {
public MyClass() {
setOnTouchListener(this);
}
@Override
public void onPageScrollStateChanged(int state) {
Log.d("Testing", TAG + " onPageScrollStateChanged");
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
Log.d("Testing", TAG + " onPageScrolled");
}
@Override
public void onPageSelected(int position) {
Log.d("Testing", TAG + " onPageSelected");
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
Log.d("Testing", "intercept");
return false;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d("Testing", "touch2");
return false;
}
}
我通常有来自 onPageScrolled 和 onPageScrollStateChanged 的日志,但我没有来自 onInterceptTouchEvent 和 onTouch 的日志。我究竟做错了什么?