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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:08:23+00:00 2026-06-10T08:08:23+00:00

My DialogButton is not dismissing even though I have .dismiss() in it. My code:

  • 0

My DialogButton is not dismissing even though I have .dismiss() in it. My code:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.iabout);
    // custom dialog
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.iabout);


    dialogButton = (Button) dialog.findViewById(R.id.btAboutOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
    }); 
}

appreciate any help.

  • 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-10T08:08:25+00:00Added an answer on June 10, 2026 at 8:08 am

    Please dont use dialog’s, please use DialogFragments. The are much easier to maintain.
    (For pre honeycomb add the support library to your project)

    Then in your DialogFragment class use the AlertDialog.Builder in the onCreateDialog(Bdl bundle) like so:

    public class MyDialogFragment extends DialogFragment {
    
    
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
    
        return new AlertDialog.Builder(getActivity())
                .setIcon(R.drawable.alert_dialog_icon)
                .setTitle(R.string.alert_dialog_custom_title)
                .setPositiveButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            ((MyActivity)getActivity()).doPositiveClick();
                        }
                    }
                )
                .setNegativeButton(android.R.string.cancel,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            ((MyActivity)getActivity()).doNegativeClick();
                        }
                    }
                )
                .create();
    }
    
    }
    

    These examples can be found here.

    At the very lease if you are going to use the old way of using dialogs please at least use the dialog builder.

    Then as per the example above you can set the callback methods.

    If you you want to do custom dialogs with custom layouts, the use DialogFragments, then you can control the dialogs lifecycle correctly and then your custom button can just call dismiss() in the DialogFragment.

    Read the examples as mentioned here.

    Cheers,
    Chris

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

Sidebar

Related Questions

I found this code on SO to automatically dismiss a confirm dialog, but it
I have the following code: <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=>'mydialog', // additional javascript options for
I’m using a jQuery mobile slider in a JQM dialog but it’s not being
I have a form in html with a default submit button. After the form
Below is part of a working normal win32 application created from scratch, not dialog
I have a modal dialog (jqueryui) that contains an accordion (jqueryui). The accordion is
In my application I have a custom dialog which display some unwanted margin at
I have used click_no_wait to click a button and then used javascript_dialog.button('OK').click to click
I have a custom dialog with an EditText and Button in it. In my
My array list somehow becomes populated. Look at this code: final ListView list =

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.