您好我创建了一个radioGroup并动态添加了radiobuttons ......
Radiogroup= (RadioGroup) findViewById(R.id.Radiogroup);
for (int i=0; i<3 i++){
Radiob = new RadioButton(Radiogroup.this);
Radiob.setText("whatever");
Radiob.setId(i);
Radiogroup.addView(Radiob);
}
问题是如何才能获得这些Radiobutton的文本?
答案 0 :(得分:0)
String[] textRadios = new String[3];
for (int i=0; i<3 i++){
Radiob = new RadioButton(Radiogroup.this);
textRadios[i]=Radiob.getText().toString();
Log.i("RadioButton: "+i, textRadios[i]);
}