I create a RadioGroup with RadioButton dynamically and I need to set one radio button by default.
I did this using both radioButton.setChecked(true) and radioButton.toggle();
The problem is that when I select another radio button at runtime, the first one is checked, so I get two checked radio buttons in the radio group.
Has anyone had this problem and knew how to solve it?
private RadioButton addRadioButton(String type, String price){ RadioButton radio = new RadioButton(Order.this); radio.setText(type + " (" + Utils.formatCurrency(price) + ")"); radio.setTextAppearance(Order.this, R.style.portalCellTextStyle); radio.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); radio.setTag(price); if(type.toLowerCase().equals("m")) radio.toggle(); return radio; }
source share