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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:18:57+00:00 2026-05-30T10:18:57+00:00

I have an Android app where I want to offer the user the choice

  • 0

I have an Android app where I want to offer the user the choice of ordering a table using different fields. I’ve used a dialog with three radio buttons to offer the choice of each sort type.

Below is the code within the dialog code which declares the radio buttons

        LayoutInflater layoutInflater = (LayoutInflater)
        getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View layout = layoutInflater.inflate(R.layout.lectindex_dialog, (ViewGroup) findViewById(R.id.lect_index));

        builder.setView(layout);

        // Now configure the AlertDialog
        builder.setTitle(R.string.exindex_title);                       

        final RadioButton radio_date = (RadioButton) findViewById(R.id.RBdate);
        final RadioButton radio_loctn = (RadioButton) findViewById(R.id.RBloctn);
        final RadioButton radio_stream = (RadioButton) findViewById(R.id.RBstream);        
        radio_date.setOnClickListener(radio_listener);
        radio_loctn.setOnClickListener(radio_listener);
        radio_stream.setOnClickListener(radio_listener);

        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // We forcefully dismiss and remove the Dialog, so it cannot be used again (no cached info)
                LecturesActivity.this.removeDialog(SELINDEX_DIALOG_ID);
            }
        });

The code for radio_listener is declared separately like so

        private OnClickListener radio_listener = new OnClickListener() {
          public void onClick(View v) {
            // Perform action on clicks
            RadioButton rb = (RadioButton) v;
            Toast.makeText(LecturesActivity.this, rb.getText(), Toast.LENGTH_SHORT).show();
          }
        }; 

Everything seems to work ok but the code for radio_listener never gets used, Why?

  • 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-30T10:18:59+00:00Added an answer on May 30, 2026 at 10:18 am

    The reason for the error and radio_listener never being called is that it throws an error when trying to using radio_date as it is not declared properly. When I changed the declaration to final RadioButton radio_date = (RadioButton) layout.findViewById(R.id.RBdate);
    Where layout is the id for the dialog the code worked perfectly.

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

Sidebar

Related Questions

I have a dialog in an Android app that I don't want the user
I have my Android app and I want to know information about user network
I have an android app it displays web view.I want know the app idle
We have an Android app and a Web Service. We want to download part
I want to develop an Android app in which I have key log press.
I am making an android app. I have a main activity and i want
I am building an android app, and I want to be able to have
I want to use MoPub for putting ads in my Android app. I have
I'm working on a relatively simple Android app. I want it to have an
I have an app that I want to develop for Android 2.1, 2.2, 2.3.3,

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.