However it seems very long winded and awkward to do it this way
RadioGroups are just long winded... You could write less code with:
TextView checked = (TextView) findViewById(amosgroup.getCheckedRadioButtonId());
atmos = checked.getText().toString();
(getCheckedRadioButtonId()
is long winded by itself!) But this assumes that the text for each RadioButton is "1", "2", etc and findViewById()
is slower than a switch statement...
Or you could use an OnCheckedChangedListener
so you don't have to call getCheckedRadioButtonId()
. But this is called every time the user clicks a new RadioButton, if you only need the "final answer", it is a few milliseconds slower.