RadioGroup with two columns which have ten RadioButtons

You can simulate that RadioGroup to make it look like you have only one. For example you have rg1 and rg2(RadioGroups with orientation set to vertical(the two columns)). To setup those RadioGroups: rg1 = (RadioGroup) findViewById(R.id.radioGroup1); rg2 = (RadioGroup) findViewById(R.id.radioGroup2); rg1.clearCheck(); // this is so we can start fresh, with no selection on both RadioGroups … Read more

Android: RadioGroup – How to configure the event listener

This is how you get the checked radiobutton: // This will get the radiogroup RadioGroup rGroup = (RadioGroup)findViewById(r.id.radioGroup1); // This will get the radiobutton in the radiogroup that is checked RadioButton checkedRadioButton = (RadioButton)rGroup.findViewById(rGroup.getCheckedRadioButtonId()); To use the listener, you do this: // This overrides the radiogroup onCheckListener rGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int … Read more

How to get the selected index of a RadioGroup in Android

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 = … Read more

Multiple radio button groups in one form

Set equal name attributes to create a group; <form> <fieldset id=”group1″> <input type=”radio” value=”value1″ name=”group1″> <input type=”radio” value=”value2″ name=”group1″> </fieldset> <fieldset id=”group2″> <input type=”radio” value=”value1″ name=”group2″> <input type=”radio” value=”value2″ name=”group2″> <input type=”radio” value=”value3″ name=”group2″> </fieldset> </form>

How to set OnClickListener on a RadioButton in Android?

I’d think a better way is to use RadioGroup and set the listener on this to change and update the View accordingly (saves you having 2 or 3 or 4 etc listeners). RadioGroup radioGroup = (RadioGroup) findViewById(R.id.yourRadioGroup); radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // checkedId is the RadioButton selected } … Read more