How do I long click on a mapview so that a place marker appears at that point on the map?
I tried a couple ways without success:
1) Using setOnLongClickListener
on the MapvView
which never detected the longclicks.
2) My other idea was to extend MapView
to override dispatchTouchEvent
.. Create a GestureDetector to respond to longpress callback. But I was stuck midway here as I could not get a handle to my subclassed Mapview. i.e.
MyMapview mymapview; //MyMapView extends MapView
//results in a classcast exception
mymapView = (MyMapView) findViewById(R.id.map);
3) The only other way I know how to try this is:
Detect a MotionEvent.ACTION_DOWN
and post a delayed runnable to a handler and detect longpress if the two other events: acton_move or an action_up, have not happened.
Can someone provide thoughts on any of these methods to detect long presses?
There's an implementation for handling long press on maps here:
http://www.kind-kristiansen.no/2011/android-handling-longpresslongclick-on-map-revisited/