Reputation: 81
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;
}
});
Upvotes: 0
Views: 572
Reputation: 6697
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.
Upvotes: 1