I have a ListView where I add a Google Map MapView into the header view, below is the code on how I do that:
vListViewTrips.addHeaderView(vMapHeaderView, null, false);
The map is shown and works but the map does not handle any gestures when its being touched even though all gestures are anebled by: googleMap.getUiSettings().setAllGesturesEnabled(true);
Based on some searches that I did I tried to extend MapView
and override the public boolean dispatchTouchEvent(final MotionEvent motionEvent)
but still the onTouchEvent
of the MapView is never called.
Here is the code:
@Override
public boolean dispatchTouchEvent(final MotionEvent motionEvent) {
ViewParent viewparent = getParent();
switch (motionEvent.getAction()) {
// Pressed on map: stop listview from scrolling
case MotionEvent.ACTION_DOWN:
viewparent.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_MOVE:
viewparent.requestDisallowInterceptTouchEvent(true);
break;
// Released on map or cancelled: listview can be normal again
case MotionEvent.ACTION_UP:
viewparent.requestDisallowInterceptTouchEvent(false);
break;
}
return super.dispatchTouchEvent(motionEvent);
}
Note im using com.google.android.gms.maps.MapView