0
我需要實現一個選擇題。我必須添加單選按鈕和文本視圖以供多項選擇。我需要根據選擇的數量動態地實現它。有人可以幫助我無線電組和單選按鈕
for (Answer answer : answers) {
LinearLayout linearLayoutRw2 = new LinearLayout(this);
linearLayoutRw2
.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
RadioGroup radioGroup = new RadioGroup(
ShowQuestionsActivity.this);
linearLayoutRw2.addView(radioGroup);
RadioButton rb = new RadioButton(ShowQuestionsActivity.this);
radioGroup.addView(rb);
TextView ansText = new TextView(ShowQuestionsActivity.this);
ansText.setText(Html.fromHtml(answer.getAnswerText()));
linearLayoutRw2.addView(ansText);
linearLayoutShowQues.addView(linearLayoutRw2);
}
我解決了這個問題,for循環和無線電roup .... – ammu
List answers = question.getAnswers(); \t \t \t如果(答案= NULL && answers.size()> 0!){ \t \t \t \t RadioGroup中radioGroup中=新RadioGroup中( \t \t \t \t \t \t MNActivity.this); \t \t \t \t int num = answers.size(); \t \t \t \t對(INT I = 0;我
ammu