I'm trying to use a FilterQueryProvider to filter some ListView contents since it should be simpler than managing this on my own, but it doesn't seem to be working as documented, or else I've missed something. My basic code for initializing the adapter is as follows:

        startManagingCursor(curs);
mAdapter = new CursorAdapter(this, curs, true); // curs has the initial full contents
        mAdapter.setFilterQueryProvider(new ItemFilter());
        setListAdapter(mAdapter);

My ItemFilter class is simply:

    class ItemFilter implements FilterQueryProvider {
        public Cursor runQuery(CharSequence filter) {
            Cursor curs = getNewCursor(filter);
            startManagingCursor(curs);
            return curs;
        }
    }

I have a key listener that updates the filter string and calls mAdapter.runQueryOnBackgroundThread() as described in the docs.

My runQuery is correctly filtering the table and returning a cursor with a subset of the full contents according to the filter string, but the ListView never changes. Some debug code calling mAdapter.getCount() always returns the original row count -- not the filtered count that I get if I call curs.getCount() in the runQuery routine. It's almost as if the adapter's changeCursor method is not being called, even though it states in the documentation that it will be called.

Did I miss something here?

Doug Gordon
GHCS Software

--
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

Reply via email to