I am making an android app in which radio buttons are to be created dynamically based on the requirement.
I used a loop to create them
The code is as follows
RadioGroup radioGroup = (RadioGroup)findViewById(R.id.answers);
for(int i=0;i<qnumber;i++)
{
pquestion.setText(qanda.get(i).question);
anstemp=qanda.get(i).answers.get(i);//Storing the answer array
for(int j=0;j<anstemp.length;j++)
{
RadioButton radioButton = new RadioButton(getBaseContext());
radioButton.setText(anstemp[j]);
radioGroup.addView(radioButton);
}
}
About the code
Different “i” values will give different number of radio buttons and radio button text
The problem I am facing is all of them continously created without clearing the previous created radio buttons
how to clear them before creating a new set of radio buttons
Here is a screen shot

I want to print only Yes,No,Niether
again clear the view and print next set of radio buttons after clearing the present radio buttons
Please help me out
did you try calling
radioGroup.removeAllViews();