【发布时间】:2018-10-13 21:39:05
【问题描述】:
我有一些代码会在活动中生成一些单选按钮:
public void drawRAnswers(int pst){
int drawables = qmclist.get(pst).getAnswers().size();
RadioGroup l1 = new RadioGroup(this);
l1.setOrientation(LinearLayout.VERTICAL);
for (int i=0;i<drawables;i++){
RadioButton rd = new RadioButton(this);
rd.setId(i);
rd.setText(current.getAnswers().get(i).getAns());
l1.addView(rd);
}
parentLinearLayout.addView(l1, parentLinearLayout.getChildCount());
}
我想要做的是能够验证单击按钮时检查了哪些(单选按钮):
public void onAddAnswer(View v){
position++;
delete();
drawRAnswers(position);
}
目前,此按钮的作用只是加载视图中的下一组单选按钮并删除当前单选按钮,但我不检查选择了哪些单选按钮。你知道我怎么能在这个onAddAnswer 方法中做到这一点吗?我想将每个选定单选按钮的文本放在一个列表中。
谢谢。
【问题讨论】:
标签: android button dynamic radio generated