[ACCEPTED]-android: Dialog, cancel button-dialog
Accepted answer
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.
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == Dialog.BUTTON_NEGATIVE)
dialog.dismiss()
}
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.
try this
dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
Button cancle_btn = (Button) dialog.findViewById(R.id.cancle_btn);
dialog_btn.setOnClickListener(new View.OnClickListener()
{
// Perform button logic
dialog.dismiss();
}
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.