Используя этот ответ: Google Maps Android API v2 - Интерактивный InfoWindow (как в оригинальных картах Google Android)
Я хочу знать, как изменить эту реализацию с onTouchListener на onItemClickedListener. Как мне изменить dispatchTouchEvent в MapWrapperLayout для работы с gridview?
Вот адаптированный OnInfoWindowElemTouchListener, реализующий OnItemClickListener для gridview
public abstract class OnInfoWindowElemTouchListener implements AdapterView.OnItemClickListener {
  private final View mainView;
  private Marker marker;
  public OnInfoWindowElemTouchListener(View view) {
    this.mainView = view;
  }
  public void setMarker(Marker marker) {
    this.marker = marker;
  }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    onItemClickConfirmed(marker, parent, mainView, position, id);
    System.out.println("click item");
  }
  protected abstract void onItemClickConfirmed(Marker marker, AdapterView<?> parent, View view, int position, long id);
}
В настоящее время используется dispatchTouchEvent из реализации onTouchListener
 @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    boolean ret = false;
    // Make sure that the infoWindow is shown and we have all the needed references
    if (marker != null && marker.isInfoWindowShown() && map != null && infoWindow != null) {
      // Get a marker position on the screen
      Point point = map.getProjection().toScreenLocation(marker.getPosition());
      // Make a copy of the MotionEvent and adjust it location
      // so it is relative to the infoWindow left top corner
      MotionEvent copyEv = MotionEvent.obtain(ev);
      copyEv.offsetLocation(
          -point.x + (infoWindow.getWidth() / 2),
          -point.y + infoWindow.getHeight() + bottomOffsetPixels);
      // Dispatch the adjusted MotionEvent to the infoWindow
      ret = infoWindow.dispatchTouchEvent(copyEv);
    }
    // If the infoWindow consumed the touch event, then just return true.
    // Otherwise pass this event to the super class and return it result
    return ret || super.dispatchTouchEvent(ev);
  }
Как я объединил его в своей деятельности внутри обратного вызова OnMapReady: this.infoWindow = (ViewGroup) getLayoutInflater(). inflate (R.layout.infowindow, null);
//Prepare infoWindow
GridView gridview = (GridView) infoWindow.findViewById(R.id.gridview);
gridview.setBackgroundResource(R.color.iconbox_bg);
gridview.setAdapter(new IconboxAdapter(this));
final MapWrapperLayout mapWrapperLayout = (MapWrapperLayout) findViewById(R.id.map_relative_layout);
mapWrapperLayout.init(gMap, getPixelsFromDp(this, 39 + 20));
this.infoButtonListener = new OnInfoWindowElemTouchListener(gridview) {
  @Override
  protected void onItemClickConfirmed(Marker marker, AdapterView < ? > parent, View view, int position, long id) {
    System.out.println("test click");
    LatLng pos = marker.getPosition();
    System.out.println("position: " + pos);
    System.out.println("marker: " + marker.toString());
  };
};
gridview.setOnItemClickListener(infoButtonListener);
gMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
  @Override
  public View getInfoWindow(Marker marker) {
    // Setting up the infoWindow with current marker info
    // We must call this to set the current marker and infoWindow references
    // to the MapWrapperLayout
    infoButtonListener.setMarker(marker);
    mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
    return infoWindow;
  }
  @Override
  public View getInfoContents(Marker marker) {
    return null;
  }
});
//Context menu
gMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
  @Override
  public void onMapLongClick(LatLng location) {
    //Create invisible marker and show custom Info Window
    MarkerOptions markerInvisible = new MarkerOptions().title("Start").alpha(0.00 f).infoWindowAnchor(0.5 f, 1);
    markerInvisible.position(location);
    Marker invisibleMarker = gMap.addMarker(markerInvisible);
    invisibleMarker.showInfoWindow();
    contextmenu = true;
  }
});
В настоящий момент это меню отображается поверх фрагмента карты, однако события click не распространяются на onItemClickConfirmed.

