一旦选中单选按钮,请帮助我如何使用单选按钮执行方法,这是我的代码:
if (RadioButton1.isChecked()){
UpdateResultsnewk();
}else if (RadioButton2.isChecked()) {
UpdateResultsoldk();
}
public void UpdateResultsnewk(){
int results1 = 100 + 10;
Textview1.setText(results);
}
public void UpdateResultsoldk(){
int results2 = 100 - 10;
Textview2.setText(results);
}
感谢。
答案 0 :(得分:0)
以下是您需要的代码:
yourRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId == yourRadioButtonWhichShouldBeChecked.getId()) {
yourMethodWhichShouldBeCalled();
}
}
});