Android中onTap和onTouchEvent的区别
我有一个应用程序显示地图和上面的一些标记。 我使用函数 draw(Canvas canvas, MapView mapView, boolean Shadow, long when)
来放置标记。如果您单击地图上的某个位置,则会出现一个 toast 并显示单击位置的地址。我使用 onTouchEvent(MotionEvent event, MapView mapView)
函数实现此功能。但我希望当您单击标记时会显示一个包含附加信息的单独对话框。在一些教程中,他们使用 onTap
来实现此目的 - onTap
和 onTouchEvent
函数之间有什么区别吗? 为了让这个对话框出现,你会推荐我任何其他(更好的)功能吗?
如何区分地图上的点击和标记上的点击?
I have an application showing the map and some markers on it.
I use the function draw(Canvas canvas, MapView mapView, boolean shadow, long when)
to put the markers. If you click somewhere on the map a toast appears and shows the address of the location clicked. I implement this with the onTouchEvent(MotionEvent event, MapView mapView)
function. But I want when you click a marker a separate dialog with additional info to show up. In some tutorials they use the onTap
for this - is there any difference between the onTap
and the onTouchEvent
functions?
And is there any other (better) function in order to make this dialog appear you would recommend me?
How to differentiate a click on the map from a click on a marker?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
onTouchEvent 涵盖任何类型的触摸事件,包括 onTap、onScroll、on Fling 等
onTouchEvent covers any kind of touch event, that include onTap, onScroll, on Fling, etc
onTap
事件通常是快速的向下和向上运动,与onClick
非常相似。onTouch
事件涵盖了所有类型的触摸事件,可以通过ACTION_DOWN
、ACTION_UP
、ACTION_MOVE
等分隔。An
onTap
event is generally a quick down and up motion that is pretty the same asonClick
. AnonTouch
event covers all types of touch events which can be separated withACTION_DOWN
,ACTION_UP
,ACTION_MOVE
, etc.