[ACCEPTED]-android: Dialog, cancel button-dialog

Accepted answer
Score: 13

Are you using the AlertDialog.Builder? There 7 are lots of way of implementing a custom 6 Dialog but assuming your "Send" button is 5 a positive or neutral button and your "Cancel" button 4 is a negative button you can always do this.

public void onClick(DialogInterface dialog, int which) {
    if (which == Dialog.BUTTON_NEGATIVE)

You 3 can also call dialog.cancel() if you want to invoke the 2 DialogInterface.OnCancelListener.

If this is not the case you need to supply 1 additional information.

Score: 2

try this

dialog = new Dialog(this);
dialog.setTitle("Custom Dialog");

Button cancle_btn = (Button) dialog.findViewById(R.id.cancle_btn);
dialog_btn.setOnClickListener(new View.OnClickListener() 
    // Perform button logic


More Related questions