You should be able to do something like this:
int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
View radioButton = radioButtonGroup.findViewById(radioButtonID);
int idx = radioButtonGroup.indexOfChild(radioButton);
If the RadioGroup
contains other Views (like a TextView
) then the indexOfChild()
method will return wrong index.
To get the selected RadioButton
text on the RadioGroup
:
RadioButton r = (RadioButton) radioButtonGroup.getChildAt(idx);
String selectedtext = r.getText().toString();