I have created a layout that includes a list view.
The data displayed in this ListView is very complex, it is mostly an array that is passed when the extended activity starts.
Rows come out of an icon and text itself, thus creating an image view and a text view. I used an array adapter to fill the list vee only because all the text items passed to an array can be shown.
Now I really want to be able to filter them, thus I got the Android: TextFilterEnabled parameter, to add to ListView XML declaration ... now a search field looks well but when If I put some letters, it will not filter, but it will only delete the entire list. I came to know that this is because the text filter does not know how to filter it.
So now my question is this: I know that I have to tell the textfilter what to filter, what I still need to fill with my array is to filter the text, add two pairs How to do?
I have extended the cursor adapter for example, but again, I do not have a cursor, I do not want to call DB I want to reuse my array with data and obviously That's the ArrayEdapter is that the data will be displayed properly on the screen (i.e. my image and textview layout).
How can this be done?
Your custom adapter must be filterable
interface, override ReturnFilter ()
and return an example of a class that extends filter
in getFilter ()
.
The way I did it was to create an example of filtering class and store it in a last
variable inside my adapter and when getFilter ()
is called.
To get a better idea of filtering yourself, look at the ArrayAdapter
source code.
Comments
Post a Comment