Stefan Doychev
Stefan Doychev

Reputation: 711

Difference between onTap and onTouchEvent in Android

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?

Upvotes: 1

Views: 2592

Answers (2)

DeeV
DeeV

Reputation: 36045

An onTap event is generally a quick down and up motion that is pretty the same as onClick. An onTouch event covers all types of touch events which can be separated with ACTION_DOWN, ACTION_UP, ACTION_MOVE, etc.

Upvotes: 0

dten
dten

Reputation: 2374

onTouchEvent covers any kind of touch event, that include onTap, onScroll, on Fling, etc

Upvotes: 2

Related Questions