0

How to add a gridview to an InfoWindow and detect click events?

See example:

enter image description here

If one of the icons inside the gridview is clicked, I want to add this icon to the map on the location the user clicked.

Code I used to show a popup menu:

gMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
      @Override
      public void onMapLongClick(LatLng location) {
        //Create invisible marker and show custom Info Window
        MarkerOptions markerInvisible = new MarkerOptions().flat(false).title("Start").alpha(0.00f).infoWindowAnchor(0,1);
        markerInvisible.position(location);
        Marker invisibleMarker = gMap.addMarker(markerInvisible);
        invisibleMarker.showInfoWindow();

        contextmenu = true;
      }
    });

Gridview:

GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(new IconboxAdapter(this));

    final Context context = this;
    gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View v,
                              int position, long id) {
        Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show();
      }
    });
Fullhdpixel
  • 803
  • 1
  • 13
  • 28

0 Answers0