Issue
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;
}
Solution
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."
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?
Answered By - Andrew Flynn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.