Use a LinkedHashmap for a cache and implement the method 'removeEldestEntry(...)' appropriately to limit the cache-size.
If the LinkedHashmap cache contains your image, code the 'getView(...)' of your list-adapter to immediately assign the (thumbnail) image to the image-view. If the LinkedHashmap cache does not contain your image, code the 'getView(...)' to assign a temporary 'loading...' placeholder to the image-view and start (asynchronously) loading the missing thumbnail. When the thumbnail is loaded, add it to the cache. When the cache changes and/or the list stops scrolling (see List13.java from the APIDemos as an example), replace any temporary 'loading...' placeholder with the newly loaded image(s). On Nov 17, 8:50 am, Paolo <brand...@gmail.com> wrote: > Hi there! > I have to manage several Bitmap in a ListView where each row is > composed by one thumbnail and one textview. > This ListView can be very long, over 500 rows... > > There are two problems I have to solve: > > 1) it is better if I cache all the bitmaps, maybe using SoftReferences > in a HashMap. I've tried this way, but I noticed a strange behavior > with the SoftReferences. It seems that the GC clean them too fast. > Why? > > 2) In order to implement the cache correctly I'd also like to > understand which is the best practice you suggest me to realize a > "image lazy loading". For example... I'm thinking to load all the data > for first and then to load only the thumbnails, but only those really > visible on the device screen at the and of the scroll action. > > Thanks in advance. > > Paolo -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en