安卓:跟踪鼠标指针的移动 [英] Android: Tracking mouse pointer movement

查看:892
本文介绍了安卓:跟踪鼠标指针的移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我使用的是通用的鼠标,它是可以跟踪X和Android中鼠标指针的Y坐标?

Assuming that I am using a generic mouse, is it possible to track the X and Y coordinates of the mouse pointer in android?

推荐答案

您需要一个 OnGenericMotionListener

OnGenericMotion(...., MotionEvent me) {
if (me.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {

}

API 14 + 需要
[确认]找到我,USB鼠标一个平板电脑和可以证实这一点适用于鼠标移动。你会用得到的消息充斥,所以简单的操作或睡觉应予以考虑。

api 14+ needed [confirmed] Found me a tablet with usb mouse and can confirm this works for mouse movement. You WILL get flooded with messages, so simple operations or sleeping should be considered.

这篇关于安卓:跟踪鼠标指针的移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆