OSDN Git Service

Ensure preference icon is returned when inflated from XML even if it has not been...
authorMichael Kwan <mkwan@google.com>
Wed, 7 Sep 2016 20:15:55 +0000 (13:15 -0700)
committerMichael Kwan <mkwan@google.com>
Wed, 7 Sep 2016 20:15:55 +0000 (13:15 -0700)
Bug: 31343032
Change-Id: Ifa2c84b3091c2cfc5b98da6f30bb1ba060cd26e7

core/java/android/preference/Preference.java

index b1cad05..ec1e102 100644 (file)
@@ -719,6 +719,9 @@ public class Preference implements Comparable<Preference> {
      * @see #setIcon(Drawable)
      */
     public Drawable getIcon() {
+        if (mIcon == null && mIconResId != 0) {
+            mIcon = getContext().getDrawable(mIconResId);
+        }
         return mIcon;
     }