ListView already has an infrastructure for filtering, which invokes the
query on a background thread:
http://developer.android.com/reference/android/widget/CursorAdapter.html#runQueryOnBackgroundThread(java.lang.CharSequence)
http://developer.android.com/reference/android/widget/CursorAdapter.html#getFilter()
http://developer.android.com/reference/android/widget/Filter.html#filter(java.lang.CharSequence)
-- Kostya
15.02.2011 17:28, Doug Gordon пишет:
I've got a ListActivity that displays a list of items from a database
using a CursorAdapter, which initially contains all items in the
table. I also provide an EditText view where the user can enter search
text, and as characters are entered, I requery the database using a
"LIKE" or "MATCH" where clause to filter the results (IOW, what lots
of apps do when searching).
Currently, I do this in an AsyncTask by creating a new Cursor from the
query, creating a new instance of my CursorAdapter class, and then
calling list.setAdapter from the UI thread when the task completes.
This is all working, but is there a more elegant way of effectively
requerying the database with a new WHERE clause from withing the
existing adapter/cursor and avoiding having to create new object
instances each time? Any examples of this technique?
Doug Gordon
GHCS Software
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en