Reputation:
I am trying to load an Image into a customized ImageView
using Picasso
.
The ImageView is generated dynamically. My problem is described as follows:
If I generate six imageviews dynamically, the image is set only on the sixth ImageView and nothing is displayed on the previous five ImageViews.
Can anyone tell me how to set the image on all 6 ImageVies. My code is as below:
for(int i=0;i<6;i++) {
imv = new RoundedImageView(Home.this);
imv.setId(i);
imv.setTag(i);
Picasso.with(Home.this).load( url ).into(target);
layout.addView(imv);
}
private Target target = new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, final Picasso.LoadedFrom from) {
Bitmap resized = Bitmap.createScaledBitmap(bitmap, 50, 50, true);
BitmapDrawable bdrawable = new BitmapDrawable(resized);
imv.setBackground(bdrawable);
}
Upvotes: 0
Views: 936