下面列出了android.graphics.drawable.Drawable#getLevel() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void switchTab(int pos) {
TextView tv = getChildAtCurPos(pos);
Drawable drawable = tv.getCompoundDrawables()[2];
int level = drawable.getLevel();
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(tv, pos, level == 1);
}
if (mLastIndicatorPosition == pos) {
// 点击同一个条目时
tv.setTextColor(level == 0 ? mTabSelectedColor : mTabDefaultColor);
drawable.setLevel(1 - level);
return;
}
mCurrentIndicatorPosition = pos;
resetPos(mLastIndicatorPosition);
//highLightPos(pos);
tv.setTextColor(mTabSelectedColor);
tv.getCompoundDrawables()[2].setLevel(1);
mLastIndicatorPosition = pos;
}
@Override
public Integer get(Drawable object) {
return object.getLevel();
}