Button on Custom Dialog Not Responding to Click Events
<p>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.</p>

<pre><code>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;
        }
     });

   …
}
</code></pre>

<p>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.</p>

<pre><code>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;
   }       
   …
}
</code></pre>

<p>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.</p>

<p>Any clues?
Thanks</p>
