嘿,伙计们有一个使用单选按钮的应用程序,如下代码
default_mode =(RadioButton)findViewById(R.id.default_mode);
warn_mode =(RadioButton)findViewById(R.id.warn_mode);
grey_mode =(RadioButton)findViewById(R.id.grey_mode);
QueGroup1 =(RadioGroup)findViewById(R.id.QueGroup1);
QueGroup1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup rg, int checkedId) {
// TODO Auto-generated method stub
for(int i=0; i<rg.getChildCount(); i++) {
//RadioButton btn = (RadioButton) rg.getChildAt(i);
if(default_mode.getId() == checkedId) {
default_method();
colorTouched();
return;
}
else if(warn_mode.getId() == checkedId)
{
warn_method();
return;
}
else if(grey_mode.getId() == checkedId){
grey_method();
return;
}
}
}
});
问题是当我在 default_mode 上选择然后在 warn_mode 上选择
名为 colorTouched() 的方法;仍在工作。我真正想知道的是如何从其他单选按钮中停止该方法。前任。如果我选择 warn_mode 方法 warn_method() 必须只工作。
提前致谢 :)))