diff options
| author | Adam Powell <adamp@google.com> | 2012-08-27 13:35:16 -0700 |
|---|---|---|
| committer | Adam Powell <adamp@google.com> | 2012-08-27 13:53:29 -0700 |
| commit | 7f02dc5c9c48a01bec459b71ac73a6ad37b9e12c (patch) | |
| tree | e17c0c085dd3d1c5ade990f8e4959b9d594f508a /core/java/android | |
| parent | e45ca31a613d8692a9db2117be96f442e57abfef (diff) | |
| download | frameworks_base-7f02dc5c9c48a01bec459b71ac73a6ad37b9e12c.zip frameworks_base-7f02dc5c9c48a01bec459b71ac73a6ad37b9e12c.tar.gz frameworks_base-7f02dc5c9c48a01bec459b71ac73a6ad37b9e12c.tar.bz2 | |
Add setOnDismissListener to AlertDialog.Builder
Add documentation to setOnCancelListener to clarify that the cancel
event plus the events for the various choice buttons are not the
exhaustive set of ways the dialog can be dismissed, and that a dismiss
listener should be used if the app needs to cover all cases of
dismissal.
Change-Id: I9e9d6f90f6f9ccaeb2c697474ab353e2d78f37b9
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 18 | ||||
| -rw-r--r-- | core/java/android/app/Dialog.java | 10 |
2 files changed, 24 insertions, 4 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); } diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 2cc3b02..16112cb 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -1106,10 +1106,12 @@ public class Dialog implements DialogInterface, Window.Callback, /** * Set a listener to be invoked when the dialog is canceled. - * <p> - * This will only be invoked when the dialog is canceled, if the creator - * needs to know when it is dismissed in general, use - * {@link #setOnDismissListener}. + * + * <p>This will only be invoked when the dialog is canceled. + * Cancel events alone will not capture all ways that + * the dialog might be dismissed. If the creator needs + * to know when a dialog is dismissed in general, use + * {@link #setOnDismissListener}.</p> * * @param listener The {@link DialogInterface.OnCancelListener} to use. */ |
