I have created RadioGroup
and RadioButton
dynamically as following:
RadioGroup radioGroup = new RadioGroup(context);
RadioButton radioBtn1 = new RadioButton(context);
RadioButton radioBtn2 = new RadioButton(context);
RadioButton radioBtn3 = new RadioButton(context);
radioBtn1.setText("Less");
radioBtn2.setText("Normal");
radioBtn3.setText("More");
radioBtn2.setChecked(true);
radioGroup.addView(radioBtn1);
radioGroup.addView(radioBtn2);
radioGroup.addView(radioBtn3);
Here step radioBtn2.setChecked(true);
causes radioBtn2
always checked. That means I cannot uncheck radioBtn2
by checking other two radio buttons (radioBtn1
,radioBtn3
). I want to make that RadioGroup
can check only one radio button at a time (Now it can check two radiobutton at a time).
How can I solve this problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…