Best way to handle multiple getView calls from inside an Adapter

Posted by Samuh on Stack Overflow See other posts from Stack Overflow or by Samuh
Published on 2010-05-20T10:52:25Z Indexed on 2010/05/24 14:51 UTC
Read the original article Hit count: 363

Filed under:
|
|

I have a ListView with custom ArrayAdapter. Each of the row in this ListView has an icon and some text. These icons are downloaded in background,cached and then using a callback, substituted in their respective ImageViews. The logic to get a thumbnail from cache or download is triggered every time getView() runs.

Now, according to Romain Guy:

"there is absolutely no guarantee on the order in which getView() will be called nor how many times."

I have seen this happen, for a row of size two getView() was being called six times!

How do I change my code to avoid duplicate thumbnail-fetch-requests and also handle view recycling?

Thanks.

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about android