How do I remove RadioButtons From RadioGroup that created Dynamically?

ashu2121

New member
Jan 15, 2015
1
0
0
How to remove RadioButtons From RadioGroup that created Dynamically

i m new in Android and making a app. I need to remove RadioButtons from RadioGroup that is created by String of Array.

What i need is to remove RadioButtons From RadioGroup and and Add new Radiobuttons. i m able to add new Radiobuttons but not able to remove old RadioButtons

for reference here is my code

RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
radioGroup = new RadioGroup(this);

final RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);



if(count==1){
for(int i =0; i<ans2.length;i++)
{
RadioButton radioButtonView = new RadioButton(this);
radioButtonView.setText(ans2);
radioGroup.addView(radioButtonView, p);
}
}
else
{
radioGroup.setVisibility(View.GONE);
}
}

Any suggestion will be helpful

thanks
 
Re: How to remove RadioButtons From RadioGroup that created Dynamically

i m new in Android and making a app. I need to remove RadioButtons from RadioGroup that is created by String of Array.

What i need is to remove RadioButtons From RadioGroup and and Add new Radiobuttons. i m able to add new Radiobuttons but not able to remove old RadioButtons

for reference here is my code

RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
radioGroup = new RadioGroup(this);

final RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);



if(count==1){
for(int i =0; i<ans2.length;i++)
{
RadioButton radioButtonView = new RadioButton(this);
radioButtonView.setText(ans2);
radioGroup.addView(radioButtonView, p);
}
}
else
{
radioGroup.setVisibility(View.GONE);
}
}

Any suggestion will be helpful

thanks


Just delete this:

if(count==1){
for(int i =0; i<ans2.length;i++)
{
RadioButton radioButtonView = new RadioButton(this);
radioButtonView.setText(ans2);
radioGroup.addView(radioButtonView, p);
}
}
else
{
radioGroup.setVisibility(View.GONE);
}
 

Members online

Forum statistics

Threads
955,028
Messages
6,963,513
Members
3,163,175
Latest member
JWIlliams1995