v1.1.6
Indicator添加setOnIndicatorItemClickListener方法用于拦截处理点击事件,
在OnItemSelectedListener监听之前触发OnIndicatorItemClickListener监听
/**
* tab项点击监听和拦截
*/
interface OnIndicatorItemClickListener {
/**
* @param clickItemView
* @param position 点击的tab的position
* @return 返回true表示 拦截点击事件,不会继续触发Indicator的setCurrent和调用OnItemSelectedListener
* 返回false 按照Indicator原有的处理方式
*/
boolean onItemClick(View clickItemView, int position);
}
使用:
indicatorView.setOnIndicatorItemClickListener(onItemClickListener);
private Indicator.OnIndicatorItemClickListener onItemClickListener = new Indicator.OnIndicatorItemClickListener() {
@Override
public boolean onItemClick(View clickItemView, int position) {
if (position == TAB_CHAT) {
startActivity(new Intent(getApplicationContext(), ChatActivity.class));
//拦截tab的事件,indicatorView不会切换当前tab,OnItemSelectedListener也不会触发
return true;
}
return false;
}
};