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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:45:09+00:00 2026-05-27T21:45:09+00:00

In my application, I am displaying the alert dialog if you click on a

  • 0

In my application, I am displaying the alert dialog if you click on a button. The alert dialog consists of multi choice items and 2 buttons(i.e, Ok and Cancel). Initially I set some items using array(i.e., in code choice_checked).

  1. If you open the alert dialog you did some changes and click on the ok button then dialog dismiss and once again open the alert dialog then it shows the changes(i.e, this default property of alert dialog).

  2. If you open the alert dialog you did some changes and click on the cancel button then dialog dismiss and once again open the alert dialog in this case i want to show the previous status only(don’t show the changes).i tried but i am not getting please can any body help me.

  3. In the code choice_checked and choice_checked_dynamic are the boolean arrays.choice_checked_dynamic is the duplicate of choice_checked. Means Initially these two arrays are same. If you did some changes in the list and click on the ok button then the changed array is copied into the choice_checked_dynamic. By default alert dialog shows the changes only so it is fine for ok button. But in case of cancel button, means if you did some changes then click on the cancel button then i want to display the choice_checked_dynamic status(means i displayed the previous status ).

I tried but i am not getting please Can anybody help me.

Code:

private OnClickListener bookmark_btnListener = new OnClickListener()

{

    public void onClick(View v)
    {
        try
        {                                   
             showDialog(DIALOG_MULTI_CHOICE);
        }
        catch(Exception ex2)
        {
            System.out.println("back btn error:"+ex2.toString());
        }
    }
};

protected Dialog onCreateDialog(int id) {
    switch (id) { 
    case DIALOG_MULTI_CHOICE:                                        
         bookmark_dialog = new AlertDialog.Builder(this);
         bookmark_dialog.setTitle("Bookmarking for");
         bookmark_dialog.setMultiChoiceItems(choice, choice_checked, new OnMultiChoiceClickListener() {
             public void onClick(DialogInterface dialog, int index, boolean status)
             {                        

             }                  
         });

         bookmark_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int whichButton) 
           {                   
               for(int i=0;i<choice_checked.length;i++)
            {
               choice_checked_dynamic[i] = choice_checked[i];               
            }
               dialog.dismiss();
           }
         });
         bookmark_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int whichButton) 
           {   
               for(int i=0;i<choice_checked_dynamic.length;i++)
               {
                    choice_checked[i] = choice_checked_dynamic[i];              
               }              
               dialog.dismiss();
           }
       });
         return bookmark_dialog.create();         
    }
    return null;
}
  • 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-27T21:45:09+00:00Added an answer on May 27, 2026 at 9:45 pm

    In the above code problem is the dialog will be create only once using onCreateDialog() if you clcik on the button first time. The Next time onwards just dialog will be open no changes are applied. So i am not recommended the onCreateDialog() for this case. Here i am creating the dialog for every button click and show it.

    // Code:
    AlertDialog.Builder bookmark_dialog_obj;
    
    private OnClickListener bookmark_btnListener = new OnClickListener()
    {
    
        public void onClick(View v)
        {
            try
        {                                   
            Bookmark_Dialog(RB_UpcomingRestaurantDetails.this); 
        }
        catch(Exception ex2)
        {
            System.out.println("back btn error:"+ex2.toString());
        }
    }
    
    
    public void Bookmark_Dialog(Context context) 
    {
    
        System.out.println("onCreate Choice_Checked:"+Arrays.toString(choice_checked));                                  
        bookmark_dialog_obj = new AlertDialog.Builder(context);
        bookmark_dialog_obj.setTitle("Bookmarking for");
        bookmark_dialog_obj.setMultiChoiceItems(choice, choice_checked, new OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int index, boolean status)
            {                     
    
            }                   
        });
    
        bookmark_dialog_obj.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) 
            {                      
                for(int i=0;i<choice_checked.length;i++)
                {
                    choice_checked_dynamic[i] = choice_checked[i];               
                }            
            }
        });
        bookmark_dialog_obj.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) 
            {   
                for(int i=0;i<choice_checked_dynamic.length;i++)
                {
                    choice_checked[i] = choice_checked_dynamic[i];              
                }      
                System.out.println("onCreate Cancel Choice_Checked:"+Arrays.toString(choice_checked));  
            }
        });
        bookmark_dialog_obj.show();         
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Java application is displaying some odd behaviour, and I'm having trouble finding a
I am developing LOB application, where I will need multiple dialog windows (and displaying
I have a web application where i am displaying an javascript alert box when
I am using Flex 4 and running into some problems displaying a simple alert
My application needs control displaying bitmaps (jpg) but also zooming and panning them (so
Ola Folks, In an iPhone application I am displaying different views by using the
I have an application that has a UILabel displaying the current date and time,
I am displaying recent comments on the home page of a blog application I
My application needs to display the time. Rather then displaying time as 11:00 I
I am having trouble displaying an background image in my ASP.NET MVC 2 application.

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.