android - "Best" way for loading many items -
I am creating a ListView in my app which can include hundreds of items over time, Are there any "best" ways to do it?
My idea is to load it into chunks (say 10-20 items). Load the first part, then when the user is about half way through the scrolling, then load the next part, add it below the list (and make sure the list does not jump about the scroll offset).
Some other ideas that I have not liked yet, they were accepting the cost of a large HTTP call and used to load all the data at once, but they scrolled while scrolling. , Or perhaps add a "Next X item" button below, or to load all the items in the list at once and keep a large list, I do not need to keep track.
I personally like my original idea. I was just thinking that there is a preferred way or it is doing this, and if there are any performance problems.
The data in question will be a JSON string, and each item will display some title text, a date, author of the item, and an image that will be downloaded using the Picasso library.
Your initial idea is my favorite approach because it works very well in most situations.
The second one can work well, but the problem is that the "big" data concept is relative relative to the devices. For powerful devices you can load up to 2000 items at a time, but it will kill the old, slow phone. Also, if you are loading 2000 items, in the case of using that code, ListView
is to select one of the first 100, then you are wasting bandwidth.
The first method is very scalable: you do not really care that if there are 5 items or 50 million, you simply remove the part while consuming the user. Memory usage is consistently with the recycling of the list view Coupled, it will have a small memory footprint.
To say something positive about the second approach: Perhaps in the case of use when ListView
is always the same data, and it rarely changes, for example , An image library, you can load all the data on the app and cache it, so you never have to make a network request, while the user is using the app if the size of the data is not large, Second approach Area I want to go. But always keep in mind that there is a significant size after which you will need the page!
Comments
Post a Comment