문제

I have like 5000 names in the database. I want all these names to be inflated onto a ListView. Which has the following elements

  1. Icon Image (which is stored locally in Drawables)
  2. Name
  3. Distance in kms

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top