简体   繁体   中英

how to recycle image from ListView in Android using custom ListAdapter and Cache View

my app that i am working seem to getting a error say that i am running out of ram. its seem working up to point then i scroll some more and and it run out of memory. i need to recycle the image in the list when the user scroll past them. but i just don't know where to begin recycle

i am using the code from this tut this is the code i am using

thanks

Here is the error in the adapter:

convertView = ( RelativeLayout ) inflater.inflate( resource, null );

you have to check if convertView is null and only if it is - create a new View, otherwise use convertView given from method params

The pattern they're implementing it's called 'Holder Pattern', and It's used to make thing load faster when having a lot of Views in a ListView, anyway, you should chekout LRU Cache Android - API 12

They use a very efficient way to load images, first looking for them in the Cache Memory, if it's available in the Cache, we load from there, If not we load the Image and add it. To the cache.!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM