我试图禁用标签在标签之间切换,我使用下面的代码。但那不起作用:
public class CustomPagerTabStrip extends PagerTabStrip {
private boolean isTabSwitchEnabled;
public CustomPagerTabStrip(Context context, AttributeSet attrs) {
super(context, attrs);
this.isTabSwitchEnabled = true;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
System.out.println("ENable?? "+isTabSwitchEnabled); // it prints out false or true based on what I have set
if (this.isTabSwitchEnabled) {
return super.onInterceptTouchEvent(event);
} else {
return true;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.isTabSwitchEnabled) {
return super.onTouchEvent(event);
}
return false;
}
public void setTabSwitchEnabled(boolean isSwipeEnabled) {
this.isTabSwitchEnabled = isSwipeEnabled;
}
}