My android using the Google map android API,InfoWindow\'s image not showing on first click, but it works on second click
I customize the infoWindow using
First you can make a custom callback class to implement the com.squareup.picasso.Callback:
private class InfoWindowRefresher implements Callback {
private Marker markerToRefresh;
private InfoWindowRefresher(Marker markerToRefresh) {
this.markerToRefresh = markerToRefresh;
}
@Override
public void onSuccess() {
markerToRefresh.showInfoWindow();
}
@Override
public void onError() {}
}
Second, declare a boolean variable in your activity:
boolean not_first_time_showing_info_window;
Third, implement the public View getInfoContents(Marker marker) method:
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.custom_window, null);
ImageView image = (ImageView)v.findViewById(R.id.image_view);
if (not_first_time_showing_info_window) {
Picasso.with(MainActivity.this).load("image_URL.png").into(image);
} else {
not_first_time_showing_info_window = true;
Picasso.with(MainActivity.this).load("image_URL.png").into(image, new InfoWindowRefresher(marker));
}
return v;
}
You can also visit this GitHub page for completed implementation.