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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:02:56+00:00 2026-05-17T17:02:56+00:00

Hi, I have created the MultiChoice AlertDialog The AlertDialog has five list items with

  • 0

Hi,

I have created the MultiChoice
AlertDialog
The AlertDialog has five
list items with checkboxes. When I
check First checkbox, w.r.t this the
if the other checkboxes in the list
are checked they shud be unchecked
automatically and vice versa.

I am checking the isChecked status
in the onClick method of
OnMultiChoiceClickListener() and calling the
showDialog(DIALOG_MULTIPLE_CHOICE); by updating boolean[]
checkedItems;
to recreate the
Dialog, But I am unable to achieve it.
If you any suggestions please direct
me to right way.

Is there any way to recreate the AleartDialog onClick event of the radio button click.

Some Sample Code below:

case DIALOG_MULTIPLE_CHOICE:
final String[] lJobTypes = { "Item1", "Item2", "Item3","Item4", "Item5" };
    return new AlertDialog.Builder(JoblistPage.this)
    // .setIcon(R.drawable.logo)
    .setTitle("Title Here")
    // .setCustomTitle(m_Title)
    .setMultiChoiceItems(lTypes, m_Selections,
        new DialogInterface.OnMultiChoiceClickListener() {

            public void onClick(DialogInterface dialog,int whichButton, boolean isChecked) {
                /* User clicked on a check box do some stuff */
                if (isChecked) {
                    m_CheckCount++;
                    //Toggle the Radio button Check status
                } else {
                    m_CheckCount--;
                }
                                                }
        }).setPositiveButton("Ok",
        new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog,
                    int whichButton) {
                    }
                }).create();

Regards
Vinayak

  • 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-17T17:02:56+00:00Added an answer on May 17, 2026 at 5:02 pm

    Don’t recreate the dialog, just toggle the checkboxes within the current dialog. Your onMultiChoiceClickListener can keep track of the currently active checkbox (if any) and uncheck it when another is selected. Here’s a complete tested, working example:

    package com.stackoverflow.beekeeper;
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.AlertDialog.Builder;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.DialogInterface.OnMultiChoiceClickListener;
    import android.os.Bundle;
    import android.widget.ListView;
    import android.widget.Toast;
    
    public class StackOverflowTest extends Activity {
      /** Called when the activity is first created. */
      @Override public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      }
    
      private int mSelected = -1;
    
      @Override protected void onResume() {
        super.onResume();
        final Builder build = new Builder(this);
        build.setTitle("List selection");
        build.setCancelable(true);
        final String[] strings = new String[]{"Cow", "Horse", "Goat"};
        final OnMultiChoiceClickListener onClick =
          new OnMultiChoiceClickListener() {
            @Override public void onClick(final DialogInterface dialog,
                                          final int which, final boolean isChecked) {
    
              if (isChecked) {
                if ((mSelected != -1) && (mSelected != which)) {
                  final int oldVal = mSelected;
                  final AlertDialog alert = (AlertDialog)dialog;
                  final ListView list = alert.getListView();
                  list.setItemChecked(oldVal, false);
                }
                mSelected = which;
              } else
                mSelected = -1;
            }
          };
        build.setMultiChoiceItems(strings, null, onClick);
        build.setPositiveButton("Done", new OnClickListener() {
          @Override public void onClick(final DialogInterface dialog,
                                        final int which) {
            String message = null;
            if (mSelected == -1)
              message = "You didn't select anything.";
            else
              message = "You selected '" + strings[mSelected] + "'";
            Toast.makeText(StackOverflowTest.this, message, Toast.LENGTH_LONG).show();
          }
        });
        build.show();
      }
    }
    

    One thing to watch for: you must specify “null” for the “checkedItems” parameter in your “setMultiChoiceItems” call — otherwise the “setItemChecked” calls won’t work as expected. It would end up using that array to store the checked state, and “setItemChecked” would’nt update it correctly, so everything would get confused. Odd, but true.

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

Sidebar

Related Questions

I have created a dialog that shows a multi-choice list of items that can
I have created a list. And I need to get the text on the
Have created a new property list, and deleted the original .plist (same filename). Deleted
Have created a ATL COM project through which I am inserting Menu Items to
Have created a custom navigation menu in wordpress that has some pages and some
I have created a UserControl that has a ListView in it. The ListView is
I have created an XML file in my solution path. My solution has multiple
I have created a windows service which is set to start automatically. This service
I have created a currency fomatter class. I want this to be a util
I have created the following C library for reading an image: typedef struct {

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.