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 852017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:31:26+00:00 2026-05-15T07:31:26+00:00

How can i retrieve the text of a dynamically created radio button selected by

  • 0

How can i retrieve the text of a dynamically created radio button
selected by the user? Here’s my code:

RadioGroup radiogroup = (RadioGroup) findViewById(R.id.rdbGp1); 
        // layout params to use when adding each radio button 
        LinearLayout.LayoutParams layoutParams = new 
RadioGroup.LayoutParams( 
                RadioGroup.LayoutParams.WRAP_CONTENT, 
                RadioGroup.LayoutParams.WRAP_CONTENT); 
 for (int i = 0; i < 4; i++){ 
            final RadioButton newRadioButton = new RadioButton(this); 
            c3 = db.getAns(3); 
        for (int j=0;j<i;j++) 
            c3.moveToNext(); 
           label = c3.getString(0); 
        newRadioButton.setText(label); 
        newRadioButton.setId(6); 
        radiogroup.addView(newRadioButton, layoutParams); 

Waiting for the reply,
Maqsood

  • 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-15T07:31:26+00:00Added an answer on May 15, 2026 at 7:31 am

    Surprised there isn’t an easier way. If you are going to do something special though based on which button you should probably checked the ID instead of the Label.

    radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
             void onCheckedChanged(RadioGroup rg, int checkedId) {
                  for(int i=0; i<rg.getChildCount(); i++) {
                       RadioButton btn = (RadioButton) rg.getChildAt(i);
                       if(btn.getId() == checkedId) {
                            String text = btn.getText();
                            // do something with text
                            return;
                       }
                  }
             }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I retrieve just text (no html tags) from a table? example: <P
I'm creating an ASP.NET control dynamically based on a value selected in a dropdown;
I have a page with 80+ dynamically generated input boxes, when the user submits
I'm trying to dynamically shorten a label based on available space. I use FormattedText
I have set the value of a hidden input element dynamically on clicking a
This is kind of a two part question. Is it possible to retrieve data
For the past few weeks, i have been using jQote – client-side templating plugin
I have a problem with this function: $(#contentdiv).click(function() { $(this).append(<div class='editable'>For some reason this
I have a class Store.java where I simply store 2 strings and an integer.
I have a Repeater bound from SQL, containing a mixture of editable and read-only

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.