Closed smoothdvd closed 11 years ago
Thanks! And Why you use OnClickListener, will GestureDetector be better?
OnClickListener is the more common, familiar interface - it's all emulated anyways - when a finger goes up on the container, a contains
test is run against each Rect registered as a hotspot - on success, it's dispatched a fake click event with no parameters, so the entirety of the gesture is being handled elsewhere anyways.
You don't need to use either class directly, just use the
addHotSpot
method, which accepts aRect
that defines the area to watch and aView.OnClickListener
to invoke.Here's the signature: http://moagrius.github.io/MapView/documentation/com/qozix/mapview/MapView.html#addHotSpot(Rect, View.OnClickListener)
A simple example might look like this (untested):
Note that the listener is passed
null
, since there's no actual View. In practice, it's not terribly useful as written above - generally you'll probably want to subclass Rect, or use a Listener factory, otherwise there's no obvious way to tie a Rect to it's listener (as you might do withView.setTag
). I'd like to expand this functionality in future releases, but for now that's what available. Feel free to hack.