我在我的活动布局中以编程方式(以放射线组和放射线按钮的数量为变量)添加放射线组,如下所示:
rg = new RadioGroup(this);
rg.setOrientation(RadioGroup.HORIZONTAL);
rg.setId(list_questions.get(i).getQuizz_questions_id()); // get from the DB
lrg.add(rg);
for (int j = 0; j < list_answers.size(); j++) {
rb = new RadioButton(this);
rb.setId(list_answers.get(j).getQuizz_answers_id());
rb.setText(String.valueOf(list_answers.get(j).getQuizz_answers_id()) + "-" + String.valueOf(list_answers.size()) + "-" + String.valueOf(list_questions.get(i).getQuizz_questions_id())); // I added that to see if there was a problem on the indexes, but there's not
rg.addView(rb, new LayoutParams(100,LayoutParams.WRAP_CONTENT));
}
tr.addView(rg, new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
Run Code Online (Sandbox Code Playgroud)
完整的代码可以在这里找到:http://pastebin.com/d9zZjmuu
我的问题是我可以在三个放射组内选择两个单选按钮.
我知道你很难提供帮助,因为你没有所有的消息来源等等但是我正在寻找问题,因为两天后我没有发现任何问题,如果你能告诉我你是否有任何问题关于问题可能来自哪里的想法将非常感谢!
谢谢,抱歉我的英语不好.