I have a ListView that is backed by a SimpleCursorAdapter.
I'd like to be able to filter the list like you would a contacts list, just by typing, and I came across the textFilterEnabled()
Problem is, I couldn't see how to get it to work with a SimpleCursorAdapter.
Is this even possible?
If so, how is it done?
The
setTextFilterEnabled()
method doesn't automatically implement filtering, as it doesn't know what in yourCursor
the text should be filtered against.This android-developers thread has more details.
Actually, there was a good question asked the other day, which actually is very similar to your question; though it originally was asking how to handle filtering when there is no physical keyboard on a device:
For a SimpleCursorAdapter cursor, you only need to use the setFilterQueryProvider, to run another query for your cursor, based on the constraint:
When a constraint is added (eg. by using a TextView) the adapter must be filtered:
Hope this helps. I will try to write a complete article , with source code the next few days.
i found this article helpful http://androidcookbook.oreilly.com/Recipe.seam;jsessionid=CE37400B3E545937B70BE2E9F94E78BB?recipeId=404
basically, you
setTextFilterEnabled(true)
on your listview, and you usesetStringConversionColumn()
andsetFilterQueryProvider()
on yourSimpleCursorAdapter
.