image not loading from URL in custom infoWindow using Picasso image loading library in android

前端 未结 3 1489
孤独总比滥情好
孤独总比滥情好 2020-12-09 13:46

I am trying to load an image from the URL in custom infoWindow when the user click on the marker. I was able to load the other details but the image is not loading int it. i

3条回答
  •  余生分开走
    2020-12-09 14:16

    You can use a Picasso Callback onsuccess loading the image, like this

    if (image != null) {
       Picasso.with(getApplicationContext())
              .load(image)
              .placeholder(R.drawable.ic_launcher)
              .into(i, new MarkerCallback(marker));
    }
    

    and create a new class to handle the Picasso Callback like this MarkerCallback.java

    public class MarkerCallback implements Callback {
       Marker marker=null;
    
       MarkerCallback(Marker marker) {
         this.marker=marker;
       }
    
       @Override
       public void onError() {
         Log.e(getClass().getSimpleName(), "Error loading thumbnail!");
       }
    
       @Override
       public void onSuccess() {
         if (marker != null && marker.isInfoWindowShown()) {
           marker.hideInfoWindow();
           marker.showInfoWindow();
         }
       }
    }
    

提交回复
热议问题