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

前端 未结 7 2037
遇见更好的自我
遇见更好的自我 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 04:00

    you can get the id of selected button by the following this.Here

    int position = group.indexOfChild(radioButton);
    

    will give you the id.Also you can to Toast to see id like this

     Toast.makeText(MainActivity.this,"Id of radio button"+position+, Toast.LENGTH_SHORT).show();
    

    This will pop up - "Id of radio button you clicked is 0" if you clicked first button.

提交回复
热议问题