From 1ad6ec205414e5848707b9212c4ae12a4b81d665 Mon Sep 17 00:00:00 2001 From: Vladislav Kaznacheev Date: Wed, 3 Feb 2016 16:12:12 -0800 Subject: [PATCH] Support resource references in pointerShape attributes. Previously pointerShape value could only be one of the system pointer shape names (such as "hand" or "arrow"). This CL introduces support for such syntax as: android:pointerShape="@drawable/custom_pointer_icon" Change-Id: Ic5276da66367fbfb8e6195434421bac0667198c1 --- core/java/android/view/View.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 4a0a0b0dbeb7c..127157b11a91b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4506,9 +4506,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } break; case R.styleable.View_pointerShape: - final int pointerShape = a.getInt(attr, PointerIcon.STYLE_NOT_SPECIFIED); - if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) { - setPointerIcon(PointerIcon.getSystemIcon(context, pointerShape)); + final int resourceId = a.getResourceId(attr, 0); + if (resourceId != 0) { + setPointerIcon(PointerIcon.loadCustomIcon( + context.getResources(), resourceId)); + } else { + final int pointerShape = a.getInt(attr, PointerIcon.STYLE_NOT_SPECIFIED); + if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) { + setPointerIcon(PointerIcon.getSystemIcon(context, pointerShape)); + } } break; }