I'm playing around with the Picasso library for image loading, but I'm running into an issue. When an image fails to load, I want to hide the view rather than load in a default image. I noticed from the source that it looks like the only way to add a listener is from the builder, but the error method is never called when an image does fail to load. Anyone have any experience with this?
iv = (ImageView) findViewById(R.id.imageView);
Picasso.Builder builder = new Picasso.Builder(getApplicationContext());
builder.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso arg0, String arg1) {
Log.e("Picasso Error", "Errored out, hiding view");
iv.setVisibility(View.GONE);
}
});
Picasso pic = builder.build();
pic.load("thisshouldbreak.jpg").into(iv);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…