I implemented the lazy-loading images in my ListView
.
I use a AsyncTask
to download the image from the internet and bind it to the ImageView in the UIThread.
It's working except that when I scroll the ListView
vary fast, the downloaded images sometimes are binded into the wrong items in the list.
I guess the problem is from the reuse of convertView
in the BaseAdapter
.
Any ideas to solve it?
Many thanks.
EDIT: I post the answer as following:
public void setBitmap(int position, Bitmap image) {
View itemView = mListView.getChildAt(position - mListView.getFirstVisiblePosition());
if (itemView != null) {
ImageView itemImageView = (ImageView) itemView.findViewById(R.id.item_imageview);
itemImageView.setImageBitmap(image);
}
}