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

  • SEARCH
  • Home
  • 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 6230165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:41:54+00:00 2026-05-24T09:41:54+00:00

How to create radio button in radioGroup in file layout without knowing exactly count

  • 0

How to create radio button in radioGroup in file layout without knowing exactly count

Dose anyone has any ideas?

  • 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-24T09:41:55+00:00Added an answer on May 24, 2026 at 9:41 am

    May be this is of any help;

    public class RadDemoActivity extends Activity {
    
        private RadioGroup radGroup;
        private Button addButton;
        private RadioButton radButton;
    
        private static int no;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            no=0;
    
            doInflateItems();
    
            setAddButton();
        }
    
    
        private void doInflateItems() {
    
            radGroup = (RadioGroup) findViewById(R.id.radGroup);
            addButton = (Button) findViewById(R.id.addRad);
        }
    
    
        private void setAddButton() {
    
            addButton.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    radButton = new RadioButton(getApplicationContext());
                    radButton.setText("Option " + no++);
    
                    radGroup.addView(radButton);
                }
            });
        }
    }
    

    XML layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <Button android:id="@+id/addRad" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="Add" />
    
    
        <ScrollView android:id="@+id/vScroll" android:layout_width="fill_parent"
            android:layout_height="wrap_content">
    
            <RadioGroup android:id="@+id/radGroup"
                android:layout_width="wrap_content" android:layout_height="wrap_content" />
    
        </ScrollView>
    </LinearLayout>
    

    This code is adding radio buttons from a button click, you can do the same from a loop if you want to add multiple buttons at once. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I grouped four radio buttons on the radiogroup. There are create file, create folder,
Any suggestions on how I would create a radio button list with an option
i am trying to create a Radio button using Cakephp like the one the
Below is sample code to create a radio button element with Yes/No options in
I need to create a row in XAML which has a label,two radio buttons..
I'm trying to create a RadioGroup within an Android layout where the child RadioButton
I'm trying to create a particular CSS button described here: http://www.2shared.com/file/5131551/412bd8a8/Sans_titre-1_copie.html Basically, it's a
I need to create radio buttons in listview. I need to select any one
I am trying to create a single-choice (e.g., radio button) list of items that
I'm trying to create a simple dynamic gallery with a radio button under each

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.