[Android] Returning to a ListView with a text filter
- by sosiouxme
I enabled text filtering on my ListView in the expected way; adding android:textFilterEnabled=”true” in resource definition and (as I'm using a SimpleCursorAdapter) setting a FilterQueryProvider that provides a filtered cursor like so:
public Cursor runQuery(CharSequence constraint) {
Cursor cur = mDba.fetchTrackers(mCurrentGroupId, constraint.toString());
startManagingCursor(cur);
return cur;
}
My question is this: once the user selects a list item, goes off to another activity, and returns to this one, how can I control the state of the filter previously applied?
What I'm seeing right now is that when I return to the activity, the cursor being used is the unfiltered one set on the filter at creation, but the filter text they typed is still shown (and typing keys causes the filter to be applied).
What I'd like to do is either clear the filter, or keep the filtered cursor that the activity was left with.