Use radio buttons when users need to see all options before they make a selection. Use radio buttons to let users select from two or more mutually exclusive options. The singular behavior of a RadioButtons group distinguishes it from check boxes, which support multi-selection and deselection, or clearing. However, once a user has selected a radio button, the user can't deselect the button to restore the group to its initial cleared state.
In the default state, no radio button in a RadioButtons group is selected. Radio buttons are always used in groups, and each option is represented by one radio button in the group.
ĪCTUALIZACIÓN: He actualizado el código desde que lo publiqué aquí.Radio buttons, also called option buttons, let users select one option from a collection of two or more mutually exclusive, but related, options. Si el diseño no es complicado, la mejor manera es usar Single RelativeLayout en lugar de múltiples Linear Layouts.Ī continuación se muestra el código con 2 filas. Para seleccionar sólo un RadioButton en esos RadioGroups los oyentes anteriores serán: private OnCheckedChangeListener listener1 = new OnCheckedChangeListener()
Para configurar esos 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 rg2.clearCheck() rg1.setOnCheckedChangeListener(listener1) rg2.setOnCheckedChangeListener(listener2) Por ejemplo, tiene rg1 y rg2 ( RadioGroups con orientación establecida en vertical (las dos columnas)). Usted puede simular que RadioGroup para que parezca que tiene sólo uno.