1

I have issue with Gridview in Android.

Context : I have a gridview, with a list of images downloaded (around 100 images).

To do it more convenient for user, a first gridview is load, with inside 100 images on which is a logo Loading. After that, I start an AsyncTask that : In onProgressUpdate => Update image with gridview.getChildAt In onPostExecute => change adapter of gridview with the list of bitmaps downloaded

My issue is in onProgressUpdate. When using getChildAt(position), I realized that position means position of the item in the visible rect. So there is two issues : => First, hidden images are not updated (it's why I'm doing an setAdapter in PostExecute) => Second, if I scroll while downloading, it forget the first images, and some other issues while scrolling, but difficult to express with word ...

My question is a little easy, but I didn't find in Android Reference, and also after Google searches : - How is it possible to update a view in a gridview by its real position, and not by visible position ?

Thanks a lot

Herfrayg
  • 11
  • 2

1 Answers1

1

Views that are not visible do not exist, so you can't update them. You can only update your backing model to have the correct information once the user scrolls to a particular item. So what you need to do is to retrieve the images and save them in a cache (or the model itself) that you can access when rendering a particular view.

However, I would suggest that there's no need to retrieve any images the user is not seeing yet.

dmon
  • 30,048
  • 8
  • 87
  • 96