0
votes

I created dynamically, n radiogroup, and every radiogroup have k radiobutton. I would like to save the checked radiobuttons text to a file, but i dont know how can i get every radiogroup checked radiobutton id.

I create the radiobutton, and radiogroup like this:

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);

            }

Please help me!

1

1 Answers

0
votes

Iterate the loop of all the RadioGroup 's

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
}