1

This is not a big issue, but it looks strange. In a list or gridview I load images with a delay (e.g. loaded from remote place). I'm recycling the items, using convertView. When I scroll down fast, I see the old images repeated, until the correct images are fetched and replace them.

Is there a way to change this? I tried, for example, at the very start of getView() (after initializing convertView, if necessary), to set the imageView visibility to GONE. And set to VISIBLE after the image has been fetched. But for some reason, this doesn't work (still looks the same).

Thanks!

Edit: I'm not even sure if this is normal behaviour when using recycled views, or if I'm doing something wrong. It doesn't look like a bug when the internet connection is fast, or when fetching from the file system. Then the new images are loaded very fast and the user doesn't see repeated items. But on a slow internet connection, it looks like a bug.

User
  • 31,811
  • 40
  • 131
  • 232
  • 1
    Show us the code for your adapter. It can likely be fixed by simply setting the image to null before starting the actual load each time getView() is called. – Michell Bak Aug 14 '12 at 22:09
  • But isn't this like setting it to `GONE`? I did a test where I set everything to `GONE` at start of `getView()`, before starting the thread, and nothing changed (don't understand why, but that's what I saw on the device...). I'll post some sample code. – User Aug 14 '12 at 22:13
  • Agh... stupid me ;P I set them to `GONE` but after some other operations set them again to `VISIBLE` before starting the fetch process... once again formatting the code for stackoverflow answered one of my questions... – User Aug 14 '12 at 22:22
  • Great! Glad you solved it :-) – Michell Bak Aug 14 '12 at 22:37

1 Answers1

0

Before setting image in row just check if the image belong to the content of view.

I had the same problem sometime back and I had to change my image downloader so that it takes image url as well as meta data so that once download is complete, i can compare meta-data with view's data.

Chitranshu Asthana
  • 1,089
  • 8
  • 19
  • But the images are set in the correct place. The problem is that android recycles the views, and *while* the image is being set, it shows the content of the old recycled view. – User Aug 14 '12 at 21:57