Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had the same problem myself, although instead of setting a <code>FilterQueryProvider</code> in the <code>SimpleCursorAdapter</code> I used an overidden <code>runQueryOnBackgroundThread(CharSequence constraint)</code> method when instantiating the <code>SimpleCursorAdapter</code>.<br> E.g. </p> <pre><code>SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.list, cursor, from, to) { @Override public Cursor runQueryOnBackgroundThread(CharSequence constraint){ Cursor cur = mDba.fetchTrackers(mCurrentGroupId, constraint.toString()); startManagingCursor(cur); return cur; } }; </code></pre> <p>But if you want to clear the filter all you need to do is get the<code>ListView</code>and call its<code>clearTextFilter()</code>method. So if your Activity extends<code>ListActivity</code>you could use the following:</p> <pre><code>ListView lv = getListView(); lv.clearTextFilter(); </code></pre> <p>Add the above lines to the method where you re-load the data in the list, i.e. whenever your<code>ListActivity</code>is shown.</p> <p>Alternatively if you want to keep the filter active and re-apply it to the<code>ListActivity</code>when the user returns to it. You can get the current filter text, that has been entered already, from the <code>ListActivity</code>as a<code>CharSequence</code>and pass it to the<code>SimpleCursorAdapter</code>'s current<code>Filter</code>:</p> <pre><code>adapter.getFilter().filter(lv.getTextFilter()); </code></pre> <p>Again add the above lines to the method where you re-load the data in the list and it will re-apply the existing filter.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload