I'm implementing an endless listview by loading more items to the arraylist in the onScrollStateChanged(...) method. If I'm implementing this scheme for fetching more than 1 million entries, I will have a million objects added to the arraylist, which is memory intensive. What schemes can I use for efficient memory management ?
PS: The question is about the number of items that can be put into the adapter. Edit:
More details:
The source of the data is Internet. I have to fetch the data from the Internet and put it into the listview adapter.
I think you should just keep the current entries and the one just before or after them(maybe 100),put this data to a cache.
When you scroll your listview,fetch more entries and update the cache as before(do not get 1 million at one time).
In Android the ListView is virtualized. Practically that means that there's no actual limit for number of elements inside it. You can put millions of rows inside the list, it'll only allocate memory for the currently visible ones (or a few more tops).
Source
Also check this article Performance Tips for Android’s ListView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With