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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:46:48+00:00 2026-06-02T17:46:48+00:00

I have a CheckBox in my code and if it’s checked, the user shouldn’t

  • 0

I have a CheckBox in my code and if it’s checked, the user shouldn’t be able to just uncheck it. This is why I decided to implement an onCheckedChangeListener on the Checkbox.

If it’s checked and clicked then confirmation is asked, else no confirmation is asked.
When confirmation is asked (through a Dialog) and the user cancels, the checkbox has to remain (or be set again to) checked. So I implemented “CheckBox.setChecked(true)” on clicking the cancel button and now my confirmation is asked twice. I don’t know how to get rid of this.

Here’s the relevant code:

    mEventAttendingCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {      
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(isChecked){
                //do nothing
            } else {
                Context mContext = EventSingleViewActivity.this;
                final Dialog dialog = new Dialog(mContext);

                dialog.setCancelable(true);

                Button confirmButton = (Button) dialog.findViewById(R.id.confirmButton);    
                confirmButton.setOnClickListener(new View.OnClickListener() { 
                    @Override
                    public void onClick(View v){ 
                        //do something
                    }
                });


                Button cancelButton = (Button) dialog.findViewById(R.id.cancelButton);  
                cancelButton.setOnClickListener(new View.OnClickListener() { 
                    @Override
                    public void onClick(View v) { 
                        dialog.dismiss();
                        mEventAttendingCheckBox.setChecked(true);
                    }
                });


                dialog.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-06-02T17:46:50+00:00Added an answer on June 2, 2026 at 5:46 pm

    Implement on CLickListener instead of onCheckChanged.. because on CLick is called only when user clicks it ,.. But OnCheckChanged gets called even when you say setChecked() in code…

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

Sidebar

Related Questions

I have the following code: function toggleChecked(status) { $(.checkbox).each( function() { $(this).attr(checked,status); }) }
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have a checkBox in my Windows application called Continuous. When user checks this
I have this code for an expandable list, I want to have a checkbox
I need to have a checkbox which ajax-submits a form. The following code throws
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
I have a table where each rows has a check box. This code works
I have a checkbox that when it is clicked it submits the form to

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.