diff options
Diffstat (limited to 'core/java/android/app/AlertDialog.java')
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index e37b3fa..7809e73 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -566,7 +566,14 @@ public class AlertDialog extends Dialog implements DialogInterface { /** * Sets the callback that will be called if the dialog is canceled. + * + * <p>Even in a cancelable dialog, the dialog may be dismissed for reasons other than + * being canceled or one of the supplied choices being selected. + * If you are interested in listening for all cases where the dialog is dismissed + * and not just when it is canceled, see + * {@link #setOnDismissListener(android.content.DialogInterface.OnDismissListener) setOnDismissListener}.</p> * @see #setCancelable(boolean) + * @see #setOnDismissListener(android.content.DialogInterface.OnDismissListener) * * @return This Builder object to allow for chaining of calls to set methods */ @@ -576,6 +583,16 @@ public class AlertDialog extends Dialog implements DialogInterface { } /** + * Sets the callback that will be called when the dialog is dismissed for any reason. + * + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder setOnDismissListener(OnDismissListener onDismissListener) { + P.mOnDismissListener = onDismissListener; + return this; + } + + /** * Sets the callback that will be called if a key is dispatched to the dialog. * * @return This Builder object to allow for chaining of calls to set methods @@ -917,6 +934,7 @@ public class AlertDialog extends Dialog implements DialogInterface { dialog.setCanceledOnTouchOutside(true); } dialog.setOnCancelListener(P.mOnCancelListener); + dialog.setOnDismissListener(P.mOnDismissListener); if (P.mOnKeyListener != null) { dialog.setOnKeyListener(P.mOnKeyListener); } |
