android maps: How to Long Click a Map?

Posted by vamsibm on Stack Overflow See other posts from Stack Overflow or by vamsibm
Published on 2009-11-05T05:15:56Z Indexed on 2010/06/07 15:32 UTC
Read the original article Hit count: 755

Filed under:
|
|
|
|

Hi. 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

mymapView = (MyMapView) findViewById(R.id.map);  //results in a classcast exception

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?

Thanks in advance. Bd

© Stack Overflow or respective owner

Related posts about android

Related posts about click