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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:05:23+00:00 2026-05-31T19:05:23+00:00

When I click on an unchecked checkbox, it gets checked and a dialog appears

  • 0

When I click on an unchecked checkbox, it gets checked and a dialog appears with Save and Cancel buttons (and other objects). When the user clicks Save, data is saved, checkbox stays checked, everyone is happy. When the user clicks Cancel, the checkbox gets unchecked, the dialog is dismissed but the else condition becomes active (opening the dialog in the else part) creating an infite loop where I click Cancel in the diagram, it is dismissed, but then the first diagram is shown and so on. How to break this loop after I click on the Cancel button that makes the checkbox unchecked/checked?

  chPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override 


public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 

                if (buttonView.isChecked()) { 
                    Log.i("cb status", "true");


                    dialog_newpass = new Dialog(Settings.this);
                    dialog_newpass.setContentView(R.layout.dialog_password_seton);
                    dialog_newpass.setTitle("      Set new password     ");
                    dialog_newpass.setCancelable(true);

                    et_newpass = (EditText) dialog_newpass.findViewById(R.id.EditText_Password);
                    et_confirmpass = (EditText) dialog_newpass.findViewById(R.id.EditText_Password2);

                     btn_SavePass = (Button) dialog_newpass.findViewById(R.id.btn_savePass);
                     btn_SavePass.setOnClickListener(new View.OnClickListener() 
                     {

                        @Override
                        public void onClick(View v) {

                            SavePassword("showpassword", "true");
                                dialog_newpass.dismiss();
                            }
                        }
                     });

                     btn_CancelPass = (Button) dialog_newpass.findViewById(R.id.btn_cancelPass);
                     btn_CancelPass.setOnClickListener(new View.OnClickListener() 
                     {
                        public void onClick(View v) 
                        {
                            dialog_newpass.dismiss();
                            chPassword.setChecked(false); //due to this, the else condition becomes active
                        }
                     });

                     dialog_newpass.show();

                }
                else
                {

                    Log.i("cb status", "false");
                    dialog_confirmpass = new Dialog(Settings.this);
                    dialog_confirmpass.setContentView(R.layout.dialog_password_setoff);
                    dialog_confirmpass.setTitle("      Enter password     ");
                    dialog_confirmpass.setCancelable(true);

                    et_pass = (EditText) dialog_confirmpass.findViewById(R.id.EditText_Password);

                    btn_SavePass = (Button) dialog_confirmpass.findViewById(R.id.btn_savePass);
                     btn_SavePass.setOnClickListener(new View.OnClickListener() 
                     {
                        @Override
                        public void onClick(View v) {
                            SavePassword("showpassword", "false");
                                dialog_confirmpass.dismiss();
                            }
                        }
                     });

                     btn_CancelPass = (Button) dialog_confirmpass.findViewById(R.id.btn_cancelPass);
                     btn_CancelPass.setOnClickListener(new View.OnClickListener() 
                     {
                        public void onClick(View v) 
                        {
                            dialog_confirmpass.dismiss();
                            chPassword.setChecked(true); //due to this, the if condition becomes active
                        }
                     });

                     dialog_confirmpass.show();

                }

            }
        });
  • 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-31T19:05:24+00:00Added an answer on May 31, 2026 at 7:05 pm

    You could add a boolean to your activity class:

    boolean canceled;
    

    Then set it to true in your cancel handler:

    btn_CancelPass.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View v) 
        {
            canceled = true;
            dialog_newpass.dismiss();
            chPassword.setChecked(false);
        }
    });
    

    And then check for it inside your else block:

    else
    {
        if(canceled){
            canceled = false;
            return;
        }
    
        // other stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code: this.Form.find(input[type=checkbox]).click(function(event) { if ($(this).is(:checked)) { console.log(checked); } else { console.log(unchecked); }
$('.lecture, .lecture > *:not(.meta)').click(function(event) { event.stopPropagation(); var myCheckbox = $(this).children(':checkbox'); if(myCheckbox.is(':checked')){ myCheckbox.removeAttr('checked'); $(this).closest('.vortrag').css({'background':'#F0F0F0'}); }else{
I have two functions. The first function translates a div click into a checked/unchecked
There is a CheckBox & Button, I want to click on Button to checked
I have check-boxes that save the index of that checkbox on click in an
I want to copy the whole rows ,but checkbox unchecked when clicking add button.(in
In the Android Mail application, when you click the checkbox next to an inbox
I have a table of data and have one checkbox per row for the
I have a link inside a label. The problem is, when user clicks 'back'
On the following page (see code at end) when I click on the checkbox

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.