I am using a pager to controll multiple fragments, count depends on data input. Each fragment displays infos about a person, also a image. I am loading the image per Picasso library in each fragment. But the fragment doesnt update after the image was loaded and set to the ImageView, so it doesnt appear on the screen. If I am closing the fragments and open them again, all images are shown.
Is it possbile to update the fragments after loaded the images, so the images appear directly on the screen?
private void setHeaderImage() {
if (stolperstein.isImageHeaderUrl()) {
Picasso.with(getContext()).load(stolperstein.getImageHeaderUrl()).into(new Target() {
@Override
public void onPrepareLoad(Drawable arg0) {
}
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom arg1) {
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
user_header_photo.setBackground(drawable);
}
@Override
public void onBitmapFailed(Drawable arg0) {
}
});
}
}
I'm not exactly sure what you're doing in the last part of your code , but if user_header_photo is an ImageView you can load it directly into it:
Picasso.with(getContext()).load(stolperstein.getImageHeaderUrl()).into(user_header_photo)