定义广播组?

时间:2018-08-15 09:48:42

标签: java android android-studio

我试图在OnCheckedChangeListener上设置RadioGroup,但是Android Studio在编写时给我一个错误。 我曾经参加过广播组

RadioGroup CheckList1 = (RadioGroup)findViewById(R.id.First_id_radio_group);
RadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener) {

}

当我按照建议(CheckList1.setOnCheckedChangeListener(...)编写它时,在Android Studio中收到以下警告,该方法被删除:

enter image description here

1 个答案:

答案 0 :(得分:0)

RadioGroup radioGroup = (RadioGroup) findViewById(R.id.yourRadioGroup);        
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        // checkedId is the RadioButton selected
    } 
});

更多详细信息:How to set OnClickListener on a RadioButton