I want to prevent Listview links from being intercepted during navigation, scaling, and compression in MapView, which is inside the Listview's list header.
I have one ListView containing all the stores. I set one list header as another xml layout and adding it to the Main ListView.
ListView List Title
<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 that extends Fragment
MapView mapView;
GoogleMap mapStoreList;
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 set the prohibition code to intercept the strokes of the 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 does not work.
But when you install an object OnTouchListenerin ListViewit, it will 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;
}
});
, ?
, 'OnTouchListerner' ListView → Child → MapView??
.