View.OnResolvePointerIcon(MotionEvent, Int32) 方法

定义

解析应在运动事件中用于指定指针的指针图标。

[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

参数

pointerIndex
Int32

要为其检索的指针 eventPointerIcon索引。 这介于 0 和 MotionEvent#getPointerCount().

返回

要用于指定指针的指针图标,或者 null 如果未指定指针图标,则应使用默认图标。

属性

注解

解析应在运动事件中用于指定指针的指针图标。

默认实现会将指针图标解析为用于 #setPointerIcon(PointerIcon) 鼠标设备的一组。 子类可以重写此项以自定义给定指针的图标。

例如,可以通过以下方式解析触笔指针的指针图标: <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文档android.view.View.onResolvePointerIcon(android.view.MotionEvent, int)

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于