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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:32:38+00:00 2026-05-20T13:32:38+00:00

I created a custom dialog that extends Dialog. One button on that the dialog

  • 0

I created a custom dialog that extends Dialog. One button on that the dialog is an “OK” button which the user is expected to press when finished entering information in other fields. I cannot get any listeners set to that button to fire.

public class HeightDialog extends Dialog {

   private Button okButton;

   …

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.heightdialog);

      this.okButton = (Button)this.findViewById(R.id.userOkWithHeight);

      this.okButton.setOnClickListener(new android.view.View.OnClickListener() {
         public void onClick(View v) {
            // Does not fire
            HeightDialog.this.dismiss();
            return;
         }
      });

      this.okButton.setOnLongClickListener(new OnLongClickListener() {
         public boolean onLongClick(View v) {
            // Does not fire
            HeightDialog.this.dismiss();
            return true;
         }
      });

     this.okButton.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
           // Does not fire
           HeightDialog.this.dismiss();
           return true;
        }
     });

   …
}

I also attempted an implementation where the Dialog class implemented the listeners(http://www.androidcompetencycenter.com/2009/01/android-basics-dialogs-and-floating-activities/) instead of using inner classes(http://about-android.blogspot.com/2010/02/create-custom-dialog.html):
Still no luck.

public class HeightDialog extends Dialog implements View.OnClickListener {

   private Button okButton;

   …

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.heightdialog);

      this.okButton = (Button)this.findViewById(R.id.userOkWithHeight);

      this.okButton.setOnClickListener(this);


   public void onClick(View view){
      HeightDialog.this.dismiss();
      return;
   }       
   …
}

I have set breakpoints inside each of the listeners in both versions of the implementation, and the debugger never stops execution. I have attempted to use inner classes for the listeners which did not solve the problem.

Any clues?
Thanks

  • 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-20T13:32:38+00:00Added an answer on May 20, 2026 at 1:32 pm

    I found a solution here:
    Handling buttons in custom dialogs

    It works in my case.

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

Sidebar

Related Questions

I created a custom autocomplete control, when the user press a key it queries
I have a conceptual question to ask: I created a custom dialog (extends Dialog)
I have created a custom dialog for Visual Studio Setup Project using the steps
I've created a custom exception for a very specific problem that can go wrong.
If have created a custom role within SqlServer which I added to the db__denydatareader
I extended JDialog to create a custom dialog where the user must fill some
I am trying to create a custom dialog box that displays an image in
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I
I've created a custom list, and made some changes to the way the CQWP
So I've created a custom RenderingTemplate and deployed it to CONTROLTEMPLATES\MyControlTemplates\ It basically dictates

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.