如何以编程方式将鼠标光标包含在android电视中 [英] How to programmatically include the mouse cursor in android tv
问题描述
我使用Webview加载随机网站.为了获得良好的导航效果,我需要打开由D-pad控制的鼠标光标,但是我没有找到有关操作方法的信息,也许有人可以开发出这种导航功能,感谢您的帮助.
I use Webview, which loads random sites. For good navigation I need to turn on the mouse cursor, which will be controlled by D-pad, but I did not find information on how to do it, maybe someone can have developed such navigation, I will be grateful for any help.
推荐答案
使用指针捕获
只有当包含视图的视图层次结构具有焦点时,它才能请求捕获指针.因此,您应该在视图上有特定的用户操作时请求指针捕获,例如在 onClick()
事件期间或在 onWindowFocusChanged()
事件处理程序中活动.
A view in your app can request pointer capture only when the view hierarchy that contains it has focus. For this reason, you should request pointer capture when there's a specific user action on the view, such as during an onClick()
event, or in the onWindowFocusChanged()
event handler of your activity.
要请求捕获指针,请在视图上调用 requestPointerCapture()
方法.下面的代码示例演示如何在用户单击视图时请求捕获指针:
To request pointer capture, call the requestPointerCapture()
method on the view. The following code example shows how to request pointer capture when the user clicks a view:
这篇关于如何以编程方式将鼠标光标包含在android电视中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!