0

I have a List that contains a huge amount of data. So filtering on text change is a little bit slow. So I thought that why should i filter all the data at a time. I want to filter limited data which will be shown in ListView. Now the question is how can i know that when ListView will ask for the next 20 data from a specific index?

More explanation: I have a ListView name list, an adapter, a List which contains 20 thousand data, and a small list(filtered). I override getView and provide data from the filtered list.

What I want to do?: When ListView needs data (a scroll or new data event occurred), filter or search in the big list until i will get next 20 or 25 data, then set them in the filtered list and show them in listView using getView. So how could i know that when listView will need the next or previous 20 data?

shantanu
  • 2,408
  • 2
  • 26
  • 56

1 Answers1

0

You first do sort all data then pass sorted data to a adapter and use ViewHolder pattern. Do not use sort in a adapter. A adapter itself calls visible indexes data in listview. ViewHolder links: http://myandroidsolutions.blogspot.com/2012/07/android-listview-tutorial.html

Faster loading ListView, faster than the Viewholder method

Creating ViewHolders for ListViews with different item layouts

if you need current get visible range of listview, you can set OnScrollListener to listview and here you can get visible range and you can call notifyDataChanges method of adapter for update listview.

Community
  • 1
  • 1
SBotirov
  • 13,872
  • 7
  • 59
  • 81