我动态地创建了无线电组,每个无线电组都有k个无线电按钮。我想将选中的无线电按钮文本保存到一个文件中,但我不知道如何才能得到每个无线电组检查的无线电按钮id。
我创建了无线电按钮,无线电组如下:
if (Integer.parseInt(cells[1])==1){
rg = new RadioGroup(this);
for (int i=2;i<cells.length;i++){
rb = new RadioButton(this);
rb.setText(cells[i]);
rb.setId(i);
rg.addView(rb);
}
lin.addView(rg);
}
请帮帮我!
发布于 2013-11-23 13:34:40
迭代所有RadioGroup的循环。
for (int i = 0; i < particularRadioGroup.getChildCount(); i++) {
RadioButton childAt = (RadioButton) particularRadioGroup.getChildAt(i);
boolean checked = childAt.isChecked();
int id = childAt.getId();
String text = childAt.getText().toString();
// Save the Data of the RadioButton of the Particluar RadioGroup
// Save Here
}
https://stackoverflow.com/questions/20162834
复制相似问题