Android - Check RadioButton ID in a RadioGroup with LinearLayout

后端 未结 2 1992
说谎
说谎 2021-01-16 23:08

Is there any possible way to get the selected radio button in this layout? because rg.getCheckedRadioButtonId() not working on this layout. I can

2条回答
  •  隐瞒了意图╮
    2021-01-16 23:47

    You can get selected radio button by this way

    int selectedId = radioGroup.getCheckedRadioButtonId();
    // find the radiobutton by returned id
    radioButton = (RadioButton) findViewById(selectedId);
    

    this will return you the id of selected radio button

提交回复
热议问题