1. ashu2121's Avatar
    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[i]);
    radioGroup.addView(radioButtonView, p);
    }
    }
    else
    {
    radioGroup.setVisibility(View.GONE);
    }
    }

    Any suggestion will be helpful

    thanks
    01-15-2015 04:41 AM
  2. LR G's Avatar
    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[i]);
    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[i]);
    radioGroup.addView(radioButtonView, p);
    }
    }
    else
    {
    radioGroup.setVisibility(View.GONE);
    }
    02-25-2015 07:06 AM

Similar Threads

  1. S4 won't charge properly and tries to turn on when plugged in
    By JulesRuby in forum Samsung Galaxy S4 Active
    Replies: 9
    Last Post: 08-17-2016, 08:56 AM
  2. Since 4.4.2 update I can't connect to wifi
    By Andy847 in forum Samsung Galaxy Note 8.0 Tablet
    Replies: 4
    Last Post: 01-19-2015, 04:29 PM
  3. How do I delete messages in bulk through computer?
    By Sandeep Kumar25 in forum Ask a Question
    Replies: 1
    Last Post: 01-15-2015, 06:07 AM
  4. Folder for saved images not being created
    By ABsmoove in forum Android 4.4 KitKat
    Replies: 1
    Last Post: 01-15-2015, 04:58 AM
  5. How do I unlock my SIM Card?
    By Challa Rao in forum Ask a Question
    Replies: 1
    Last Post: 01-15-2015, 12:04 AM
LINK TO POST COPIED TO CLIPBOARD