Sdílet prostřednictvím


View.OnResolvePointerIcon(MotionEvent, Int32) Method

Definition

Resolve the pointer icon that should be used for specified pointer in the motion event.

[Android.Runtime.Register("onResolvePointerIcon", "(Landroid/view/MotionEvent;I)Landroid/view/PointerIcon;", "GetOnResolvePointerIcon_Landroid_view_MotionEvent_IHandler", ApiSince=24)]
public virtual Android.Views.PointerIcon? OnResolvePointerIcon (Android.Views.MotionEvent? e, int pointerIndex);
[<Android.Runtime.Register("onResolvePointerIcon", "(Landroid/view/MotionEvent;I)Landroid/view/PointerIcon;", "GetOnResolvePointerIcon_Landroid_view_MotionEvent_IHandler", ApiSince=24)>]
abstract member OnResolvePointerIcon : Android.Views.MotionEvent * int -> Android.Views.PointerIcon
override this.OnResolvePointerIcon : Android.Views.MotionEvent * int -> Android.Views.PointerIcon

Parameters

pointerIndex
Int32

The index of the pointer in event for which to retrieve the PointerIcon. This will be between 0 and MotionEvent#getPointerCount().

Returns

the pointer icon to use for specified pointer, or null if a pointer icon is not specified and the default icon should be used.

Attributes

Remarks

Resolve the pointer icon that should be used for specified pointer in the motion event.

The default implementation will resolve the pointer icon to one set using #setPointerIcon(PointerIcon) for mouse devices. Subclasses may override this to customize the icon for the given pointer.

For example, the pointer icon for a stylus pointer can be resolved in the following way: <pre> &#64;Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { final int toolType = event.getToolType(pointerIndex); if (!event.isFromSource(InputDevice.SOURCE_MOUSE) && event.isFromSource(InputDevice.SOURCE_STYLUS) && (toolType == MotionEvent.TOOL_TYPE_STYLUS || toolType == MotionEvent.TOOL_TYPE_ERASER)) { // Show this pointer icon only if this pointer is a stylus. return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_WAIT); } // Use the default logic for determining the pointer icon for other non-stylus pointers, // like for the mouse cursor. return super.onResolvePointerIcon(event, pointerIndex); } </pre>

Java documentation for android.view.View.onResolvePointerIcon(android.view.MotionEvent, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to