I have like 5000 names in the database. I want all these names to be inflated onto a ListView. Which has the following elements
I am filtering this listView using Search Filtering, something like this:
adapter.getFilter().filter(someText);
I am also sorting the listview, for example: sort listView names alphabetically(A-Z and Z-A). Sorting is done on the listView adapter like this:
adapter.sort(new Comparator<String>() {
@Override
public int compare(String lhs, String rhs) {
return lhs.getPlaceName().compareTo(rhs.getPlaceName());
};
});
Now i am pretty confused whether to use Lazy loading of names onto the listview(because I have 5000+ names) considering the performance of the adapter. Please suggest.
Alternatively, you may store your data in the database sorted and then apply lazy loading. Because though approach suggested by @Singularity in very good, you may end up sorting only chunks [of 100, say] and not the whole data. Also, you would require sorting to be done for each of those chunk.