我在我的活动布局中以编程方式添加(必须作为单选组和单选按钮的数量是变量)单选组:
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));
完整的代码可以在这里找到:http: //pastebin.com/d9zZjmuu
我的问题是我可以在三个单选组中选择两个单选按钮。
我知道您很难提供帮助,因为您没有所有资源等问题出在哪里的想法将不胜感激!
感谢和抱歉我的英语不好。