Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:47:58+00:00 2026-05-25T06:47:58+00:00

I have Radio buttons that are created dynamically. LinearLayout linLayRoot = (LinearLayout)dialogView.findViewById(R.id.dialog_layout_root); RadioGroup radGp

  • 0

I have Radio buttons that are created dynamically.

                     LinearLayout linLayRoot = (LinearLayout)dialogView.findViewById(R.id.dialog_layout_root);
         RadioGroup radGp = new RadioGroup(this);
         linLayRoot.addView(radGp);

         for (String dir : dirArray)
         {

                LinearLayout linLayNew = new LinearLayout(this);
                linLayNew.setGravity(0x10);
                RadioButton radBut = new  RadioButton(this); /// <- this button does not work!
                radBut.setText("");
                TextView tv = new TextView(this);
                tv.setText(dir);
                tv.setPadding(10, 0, 20, 0);
                ImageView ivs = new ImageView(this);

                linLayNew.addView(radBut);
                linLayNew.addView(tv);
                linLayNew.addView(ivs);

                radGp.addView(linLayNew);

         }

            RadioButton radBut1 = new  RadioButton(this); /// <- this button works!
            radBut1.setId(11);
            radBut1.setText("a1");
            radGp.addView(radBut1);

            RadioButton radBut2 = new  RadioButton(this); /// <- this button works!
            radBut2.setId(12);
            radBut2.setText("b2");
            radGp.addView(radBut2);

         radGp.setOnCheckedChangeListener( new OnCheckedChangeListener()
         {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                Toast.makeText(getApplicationContext(), String.valueOf(checkedId) , Toast.LENGTH_SHORT).show();
            }
         });

But as you can see from the comments above, they don’t really work, i.e. seems that they aren’t binded to the radGp… maybe its because they are in a separate linlearlayout?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:47:58+00:00Added an answer on May 25, 2026 at 6:47 am

    Add your RadioButtons in a List<RadioButton> and you can check them then by using

        mRadioList.get(i).setChecked(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some radio buttons that are created dynamically with javascript. I need to
I have a dynamically created list that displays radio buttons next to it. When
I have several radio buttons that are dynamically populated on a form and I
I have a set of radio buttons that are dynamically generated (via JSON call):
I have this set of labels and radio buttons that look like this: Entertainment:
I have created RadioGroup and RadioButton dynamically as following: RadioGroup radioGroup = new RadioGroup(context);
On my page, I have a dynamically generated list of radio buttons (created with
I have got a group of radio buttons that when clicked need to display
I have two radio buttons on my MVC form that I use to hide
i have 3 radio buttons.what i need to do is that when one radio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.