Recycling views in scrollview in android

I have scrollview

one in which I inflated the view dynamically (just like the facebook wall android app, it has imageview

and textview

.).
All images are dynamic. If I load too much data into it I get outofmemory exception

. I know it listview

will solve my problem, but I cannot use listview

.
So, is there a way to optimize ie to recycle views when they are not visible?

+3


source to share


2 answers


From your comments, I believe you can still use the list view:

The list can take many different forms. For more information on this, read Android ListView with different layouts for each row .



This way the views will be reworked and hopefully your memory usage will be less.

Anyway , I would probably investigate your code as I suppose you are probably leaking objects or doing something too many times to run out of memory.

+2


source


you can not handle Errors in normal circumstance but you can use following techneques to remove thias errror
1-Please clear your Arraylist before item add .
2-Use garbage collection techniques 
System.gc() or finalize method use for Memory reclaim from object.

      



+1


source







All Articles