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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:12:57+00:00 2026-06-17T21:12:57+00:00

I am using a dialog with 2 radio buttons to get the user to

  • 0

I am using a dialog with 2 radio buttons to get the user to classify an object. This works if the user explicitly clicks on one of the radio buttons but not if they simply press OK straight away. How can I handle this situation?

case DIALOG_OBJECT_CLASSIFICATION:
        return new AlertDialog.Builder(DrawNewPlans.this)
                .setIcon(R.drawable.alert_dialog_icon)
                .setTitle("What Object are you drawing?")
                .setSingleChoiceItems(R.array.types_of_object, 0,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int whichButton) {
                                makeToast("WhichButton = "+whichButton);
                                switch (whichButton) {
                                    case 0:
                                        makeToast("User Picked Room");
                                        isRoom = true;
                                        isFurniture = false;
                                        return;
                                    case 1:
                                        makeToast("User Picked Furniture");
                                        isRoom = false;
                                        isFurniture=true;
                                        return;
                                }
                                /* User clicked on a radio button do some stuff */
                            }
                        })
                .setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int whichButton) {
                                makeToast("classOfRoom is "+classOfRoom);
                                makeToast("isRoom = "+isRoom);
                                makeToast("isFurniture = "+isFurniture);
                                if (isRoom == true && isFurniture == false) {
                                    classOfRoom="Room";
                                } else if (isRoom == false && isFurniture == true) {
                                    classOfRoom="Furniture";
                                }
                                /* User clicked Yes so do some stuff */
                                isClassified=true;
                                methodWhichStartsDialogs();
                            }
                        })
                .setNegativeButton("Cancel",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int whichButton) {

                                /* User clicked No so do some stuff */
                            }
                        }).create(); 
    }

I just added the Toasts for debugging. Many 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-06-17T21:12:58+00:00Added an answer on June 17, 2026 at 9:12 pm

    You can either set one radio button to be true by default, that is even if the user doesn’t select anything, that option will be selected by default.

    Or, otherwise, you can check if atleast one of the radio buttons are selected when the user presses okay. If none has been selected, do not dismiss the dialog.

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

Sidebar

Related Questions

It is possible using Dialog class but I do not want it that way.
I have a WinForms dialog box that contains 3 radio buttons. I am using
So what I'm attempting to do is this: User clicks a radio html form
I am using MonoTouch.Dialog's OwnerDrawnElement, but it doesn't seem to allow the user to
When I'm initializing a dialog, I'd like to select one of the radio buttons
I am using dialog plugin from jQuery UI 1.8.17. The following code works and
I open a form as a modal dialog using ShowDialog. This dialog in turn
Im using a System.Windows.Controls.PrintDialog to let the user print one or more pages from
I am using Theme.Dialog activity to display user a reminder whenever Alarm triggers, It
I have an MFC dialog in which there are two radio buttons. I have

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.