2013年1月31日 星期四

How to Handle The long and large Image Resource on Android's ListView

   Use listView with item that have ImageView is normal situation for Application. but the android will catch OutOfMemoryExceptions when the list is too long even if you use the SimpleAdapter. the BaseAdapter interface without method like dispose() let the item to release the resource when it's invisible.

   so the official site post a article : Displaying Bitmaps Efficiently. looks like the Caching Bitmaps can solve the problem. but the LruCache work on API 12. I think the key issue is we can not get the heap size on a Bitmap(but the interface is open in API 12 Bitmap.getByteCount()).
 
   finally we found the open source projects to handle this kind of problem. The ImageLoader and Android-Universal-Image-Loader. but it's only for resource from Internet and File(that's means the resource in assets can't support). the implementation use View.setTag(java.lang.Object) to link the ImageLoader and View.


沒有留言:

張貼留言