setTag,getTage复用

radioButtons = new RadioButton[rgMain.getChildCount()];  //遍历RadioGroup
for (int i = 0; i < radioButtons.length; i++) {
radioButtons[i] = (RadioButton) rgMain.getChildAt(i);
radioButtons[i].setTag(i);                //设置tag
radioButtons[i].setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b)
//切换ViewPager页面
showFragment((int) compoundButton.getTag());    //获取tag
}
});
}
上一篇:ES6笔记-字符串方法


下一篇:SCWS 中文分词_测试成功