有人可以告诉我我在哪里做错了吗?为什么即使我将它们放入 RadioGroup 中,也可以选择两个 RadioButton?
这是代码:
final Dialog dialog = new Dialog(context);
LinearLayout ll = new LinearLayout(context);
ll.setOrientation(LinearLayout.VERTICAL);
dialog.setTitle("Title");
RadioButton rb_yes = new RadioButton(context);
rb_yes.setText("yes");
RadioButton rb_no = new RadioButton(context);
rb_no.setText("no");
rb_no.setChecked(true);
RadioGroup radioGroup = new RadioGroup(context);
radioGroup.setOrientation(RadioGroup.VERTICAL);
radioGroup.addView(rb_yes);
radioGroup.addView(rb_no);
ll.addView(radioGroup);
// "context" I've already created before (Context context = this)