如何以编程方式为单选按钮设置组?

时间:2013-02-19 16:14:55

标签: java android

我有以下代码:

mRadioButtonEveryDay=(RadioButton)findViewById(R.id.activityNewGoalRepeatEveryDay);
mRadioButtonEveryWeek=(RadioButton)findViewById(R.id.activityNewGoalRepeatEveryWeek);
mRadioButtonEveryBiWeek=(RadioButton)findViewById(R.id.activityNewGoalRepeatEveryBiWeek);
mRadioButtonNeverRepeating=(RadioButton)findViewById(R.id.activityNewGoalNeverRepeating);

mRadioGroupRepeating=new RadioGroup(this);
mRadioGroupRepeating.clearCheck();

存在以下问题:我不知道如何将RadioButton添加到RadioGroup,因为mRadioGroupRepeating的方法“addView()”会抛出异常,即我必须在将RadioButtons添加到RadioGroup之前删除它。有没有最简单的方法呢?

0 个答案:

没有答案