I want to disallow intercept touches of Listview while Moving, zooming & pinch in MapView which is inside Listview's Header View.
I have one ListView contains all stores. I have set one List View Header as another layout xml and adding it to Main ListView.
ListView Header
<com.google.android.gms.maps.MapView
android:id="@+id/mapViewStores"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="10dp" />
StoreList.java which extends Fragment
MapView mapView; //Map View
GoogleMap mapStoreList; //For Markers on Map
listViewStoreData.addHeaderView(headerViewForStoreList);
mapView = (MapView) headerViewForStoreList
.findViewById(R.id.mapViewStores);
mapView.onCreate(savedInstanceState);
if (mapView != null) {
mapStoreList = mapView.getMap();
mapStoreList.getUiSettings().setMyLocationButtonEnabled(true);
mapStoreList.setMyLocationEnabled(true);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(
new LatLng(latitude, longitude), 13);
mapStoreList.animateCamera(cameraUpdate);
}
I have set code for disallow for Intercept touches of parent view
mapStoreList.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
case MotionEvent.ACTION_DOWN:
this.getParent().requestDisallowInterceptTouchEvent(true);
break
}
return super.onTouchEvent(ev);
}
});
Unfortunately, it's not working.
But when set OnTouchListener
to ListView
object, it'll log events.
listViewStoreData.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Log.e("MotionEvent", "Move");
break;
case MotionEvent.ACTION_UP:
Log.e("MotionEvent", "Up");
break;
case MotionEvent.ACTION_DOWN:
Log.e("MotionEvent", "Down");
break;
case MotionEvent.ACTION_CANCEL:
Log.e("MotionEvent", "Cancel");
break;
case MotionEvent.ACTION_POINTER_INDEX_MASK:
Log.e("MotionEvent", "Pointer Index Mask");
break;
case MotionEvent.ACTION_POINTER_INDEX_SHIFT:
Log.e("MotionEvent", "Pointer Index Shift");
break;
}
return false;
}
});
So, how do I overcome from this situation ?
Is there any possibility that we cannot get 'OnTouchListerner
' for ListView
's Child -> Header View's Child -> MapView
??
Any help will be appreciated.