Friday 4 November 2011

Android Annoyances: RadioGroup

I have a RadioGroup with two RadioButtons in it. In the code, I want to know which of the buttons was selected. Here is the way to find out that information using Android API:

int index = group.indexOfChild(group.findViewById(group.getCheckedRadioButtonId()));

Pure elegance…