diff options
author | Adam Powell <adamp@google.com> | 2011-01-07 22:30:48 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-01-08 13:09:51 -0800 |
commit | 947f7824118f0e9b642df8760a8725a7eda59318 (patch) | |
tree | e0394b7dd4a05f45564cae756c76fe1860da5a35 /core/java/android/app | |
parent | 4d46ecb0759d5adfdb4015a27e2a596115180286 (diff) | |
download | frameworks_base-947f7824118f0e9b642df8760a8725a7eda59318.zip frameworks_base-947f7824118f0e9b642df8760a8725a7eda59318.tar.gz frameworks_base-947f7824118f0e9b642df8760a8725a7eda59318.tar.bz2 |
Fix bug 3245465 - Themed dialog icons
Added light/dark versions of holo dialog icons. Apps using
AlertDialogs that wish to use the system dialog icon should use
setIconAttribute(android.R.attr.alertDialogIcon) instead of
setIcon(android.R.drawable.ic_alert_dialog).
Change-Id: I40793a3164478be5ffa045ededfcab8210753a4b
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/AlertDialog.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index 9850a12..70e3616 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -270,6 +270,17 @@ public class AlertDialog extends Dialog implements DialogInterface { mAlert.setIcon(icon); } + /** + * Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon + * + * @param attrId ID of a theme attribute that points to a drawable resource. + */ + public void setIconAttribute(int attrId) { + TypedValue out = new TypedValue(); + mContext.getTheme().resolveAttribute(attrId, out, true); + mAlert.setIcon(out.resourceId); + } + public void setInverseBackgroundForced(boolean forceInverseBackground) { mAlert.setInverseBackgroundForced(forceInverseBackground); } @@ -399,7 +410,19 @@ public class AlertDialog extends Dialog implements DialogInterface { P.mIcon = icon; return this; } - + + /** + * Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon + * + * @param attrId ID of a theme attribute that points to a drawable resource. + */ + public Builder setIconAttribute(int attrId) { + TypedValue out = new TypedValue(); + P.mContext.getTheme().resolveAttribute(attrId, out, true); + P.mIconId = out.resourceId; + return this; + } + /** * Set a listener to be invoked when the positive button of the dialog is pressed. * @param textId The resource id of the text to display in the positive button |