我正在尝试实现代码来为两个单选按钮组设置侦听器 这是使我的应用崩溃的代码
genderOption.setOnCheckedChangeListener(
//anonymous class
new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
//referencing an object to retrieve Id
RadioButton rb = (RadioButton)radioGroup.findViewById(checkedId);
switch (rb.getId()){
case R.id.rbMale:
maleGender.setText("Boy");
break;
case R.id.rbFemale:
femaleGender.setText("Girl");
break;
}
//end of switch
}
});
/*End of listening to clicks on radio buttons*/