Picasso - Load Image Into Imagebutton In Adapter
I want to load an image into a ImageButton in an adapter, this is sometimes not working... I have a adapter with 4 entries, and sometimes, the button image is just loaded 2 times i
Solution 1:
Use Target
private Target loadtarget;
Write this code in getView()
if (loadtarget == null)
loadtarget = newTarget() {
@OverridepublicvoidonBitmapFailed(Drawable arg0) {
}
@OverridepublicvoidonBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
handleLoadedBitmap(bitmap);
}
@OverridepublicvoidonPrepareLoad(Drawable arg0) {
}
};
try {
Picasso.with(this).load(url).into(loadtarget);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
}
publicvoidhandleLoadedBitmap(Bitmap b) {
BitmapDrawable bdrawable = newBitmapDrawable(b);
imageButton.setBackgroundDrawable(bdrawable);
}
Hope this will help you :)
Post a Comment for "Picasso - Load Image Into Imagebutton In Adapter"