0

I'm trying click into a "Window" of Google Maps, but my button doesn't work, I think that is problem of the handler, because it is encapsulated "@listener" (android not work correctly) but I don't know exactly.

My code to click is here :

googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {

    // Use default InfoWindow frame
    @Override
    public View getInfoWindow(Marker arg0) {
        return null;
    }

    // Defines the contents of the InfoWindow
    @Override
    public View getInfoContents(Marker arg0) {
        View v = getLayoutInflater().inflate(R.layout.windowlayout, null);

        LatLng latLng = arg0.getPosition();

        TextView tvLat = (TextView) v.findViewById(R.id.tv_lat);

        TextView tvLng = (TextView) v.findViewById(R.id.tv_lng);

        tvLat.setText("Latitude:" + latLng.latitude);

        tvLng.setText("Longitude:"+ latLng.longitude);
        Button btn  = (Button)v.findViewById(R.id.btn); // Here my button not work 
        btn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Toast.makeText(GoogleMapActivaFind.this, "wow", Toast.LENGTH_SHORT).show();
                    }
                });
        return v;
    }
});
476rick
  • 2,764
  • 4
  • 29
  • 49
Calimbo
  • 81
  • 1
  • 3
  • 13
  • Check my answer to the post [Assign a click listener to the info window, cannot navigate to the webpage Google Maps V2](http://stackoverflow.com/questions/29302927/assign-a-click-listener-to-the-info-window-cannot-navigate-to-the-webpage-googl/29305877#29305877) – Xcihnegn Apr 27 '15 at 17:11
  • but I need more button, not only 1.... as this imatge http://stackoverflow.com/questions/15090148/custom-info-window-adapter-with-custom-data-in-map-v2 – Calimbo Apr 27 '15 at 19:00
  • ok just see the infowindow, but i think the like and dislike button not for click, but just show info – Xcihnegn Apr 27 '15 at 19:13
  • when you click infowindow then go to the detail page for the place, then there will like and dislike button for click, do you agree with me? – Xcihnegn Apr 27 '15 at 19:15
  • I agree, the structure is different, but the goal is to have many buttons. – Calimbo Apr 27 '15 at 19:23
  • you can have many buttons/icons on infowindow, but not for clicking – Xcihnegn Apr 27 '15 at 19:36
  • I know, but how I can make buttons in a view for click ? – Calimbo Apr 27 '15 at 19:51
  • in which view you mean? – Xcihnegn Apr 27 '15 at 19:55

1 Answers1

1

It's not possible:

Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.

Source: Info Windows.

However you can use GoogleMap.OnInfoWindowClickListener to listen to click events on an info window.

Ziem
  • 6,579
  • 8
  • 53
  • 86