android 异步加载 头像错乱

public synchronized static void setPhotoSmall(ImageView imageView, String iamgeUrl, final View listView) {
try {
imageView.setTag(iamgeUrl);
Drawable bitmap = getInstance().loadImage(iamgeUrl, new OnImageLoadListener() {
public void onImageLoad(Drawable drawable, String url) {
ImageView imageViewByTag = (ImageView) listView.findViewWithTag(url);
if (imageViewByTag != null) {
if (drawable != null) {
imageViewByTag.setImageDrawable(drawable);
} else {
imageViewByTag.setImageResource(R.drawable.nvren);
}
}
}
});

if (bitmap == null) {
imageView.setImageResource(R.drawable.nvren);
} else {
imageView.setImageDrawable(bitmap);
}
} catch (Exception e) {
Log.e(AsyncSmallLoader.class.getName() + ".setPhotoSmall", e.toString());
}
}


解决头像错乱的关键代码:

imageView.setTag(iamgeUrl);
listView.findViewWithTag(url);



你可能感兴趣的:(android 异步加载 头像错乱)