Issue
I'm a novice Android monkey and I've hit a snag trying to implement a feature on my app. What I want to do is have my users be able to long click an overlay item (it's a bus stop) and add that marker (stop number and address) to their favorites tab. The problem is... how do I listen for and handle a long click(tap) on an overlay item??
Currently I'm @overriding the onTap function in my Overlay class to handle regular taps, but I don't see an onLongTap function to override in the documentation... Can anyone set me along the right path? Am I missing something obvious here? Thanks for reading this
P.S. This is my first SO question :-)
Solution
You probably want to override onTouchEvent(MotionEvent, MapView)
for more complex user interactions. For a 'long' tap, you should start some sort of timer that will indicate how long the user has been pressing on a specific Overlay item. Once a certain threshold is reached - I believe the default delay for a 'long' press is roughly 1500 ms - you then execute the relevant code.
Alternatively, you could take a look at including the mapview-overlay-manager project, which, from the reads of it, should offer exactly what your looking for (and then some):
OnOverlayGestureListener
Simplified OnGestureListener. A ManagedOverlayer uses its own build-in GestureDetector that fires events like:
- onSingleTap(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
- onDoubleTap(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
- onLongPress(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
- onZoom(ZoomEvent, ManagedOverlay) onScrolled(...)
Answered By - MH.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.