How to get the id of selected radio button in android?

前端 未结 7 1996
遇见更好的自我
遇见更好的自我 2020-12-17 03:23

I am working on quiz application in android. We have created Select.java page which displays the questions and options(with radio buttons) from sqlite datab

7条回答
  •  旧巷少年郎
    2020-12-17 03:55

    In RadioGroup Class you can use method getCheckedRadioButtonId();

    RadioGroup rg = findViewById(R.id.radioGroup); rg.getCheckedRadioButtonId();

    Returns the identifier of the selected radio button in this group. Upon empty selection, the returned value is -1.

提交回复
热议问题