Android - 获取鼠标点击的像素的坐标
我正在制作一个 Android 应用程序,它使用谷歌地图。一项功能是用户可以触摸地图上的一点并检索坐标。我在这里找到了一个很棒的教程 http://mobiforge.com/developing /story/using-google-maps-android?page=1 显示了如何使用 MotionEvent 实现此功能(您可以在教程中的“获取触摸的位置”下找到代码)。
我的问题是模拟器似乎不支持触摸事件,而且我没有 Android 设备可以随时测试它。所以我想要一种方法,它允许我用鼠标单击屏幕并获取所单击像素的坐标(以便将它们转换为地理坐标)。
从我到目前为止的研究来看,我找不到任何合适的东西,而且我也不否认是否有东西存在。有人可以帮忙吗?
I’m making an android app, which uses Google maps. One functionality is that the user may touch on a point of the map and retrieve the coordinates. I found a great tutorial here http://mobiforge.com/developing/story/using-google-maps-android?page=1 which shows how to implement this with a MotionEvent (you can find the code on the tutorial under "Getting the Location that was touched").
My problem is that touch events seem not to be supported by the emulator and I do not have an android device to test it anytime. So I would like to have a method, that allows me to click the screen with the mouse and get the coordinates of the pixel that was clicked (so to transform them to geocoordinates).
From my research so far I couldn’t find anything that fits and I do not no if something exists. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将帮助你:
oncreate代码:
覆盖层的内部类将响应触摸(单击模拟器)
This will help u out:
oncreate code:
inner class for overlay that will respond to touch (click on emulator)
我想您会发现该特定教程也会响应鼠标点击。毕竟所有屏幕截图都是模拟器的。
关于作者编码风格的一点说明:
while
will 的作用
是相同的,但更具描述性和更好的实践
I think you'll find that particular tutorial will respond to mouse clicks too. After all the screen shots are of an emulator.
Just one note on the author's coding style:
whilst
will work
amounts to the same thing but is more descriptive and better practice