I have an activity which extends MapActivity. But when I tap the map, the onTouchEvent never gets called. Why is this?
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("temp", "onTouchEvent");
return true;
}
edit: I now have these 2 methods in a custum created ItemizedOverlay to catch my events. The first one gets called when I tap an overlay. But the second (onTouchEvent) never get's called when I touch the map.
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
this.movement = true;
Log.d("temp", "overlayItem tapped" + item.getTitle());
return true;
}
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
this.movement = false;
Log.d("temp", "overlayItem tapped finish");
return true;
}
The MapView associated with a MapActivity almost certainly handles the view for you. If you look at the docs for Activity#onTouchEvent() it says: "Called when a touch screen event was not handled by any of the views under it."
http://developer.android.com/reference/android/app/Activity.html#onTouchEvent(android.view.MotionEvent)
I'm guessing what you want to do with that touch event is already handled by the MapView, maybe find the right place to put it inside of that code?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With