I created a custom dialog that extends Dialog. One button on this dialog box is the OK button, which the user must click when finished entering information in other fields. I cannot get listeners to set this button to run.
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) {
I also tried to implement an implementation in which the Dialog class implemented 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): Not lucky yet.
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 set breakpoints inside each of the listeners in both versions of the implementation, and the debugger never stops execution. I tried using inner classes for listeners who did not solve the problem.
Any clues? Thanks
android
Mike
source share