How to create a ListView filter with SimpleCursorAdapter on Android

I will make a filter for a list from am SimpleCursorAdapter. I see a toast following my example, but nothing happens to the filter. I found an example with setFilterQueryProvider. But I do not know to implement this. Here's my code:

    Cursor entryCursor = mDatabase.query(
            new String[] {
            null, null, null, null, null);

    final SimpleCursorAdapter entryAdapter =
        new SimpleCursorAdapter(this,
                new String [] {"name",
                new int[] {,


    final ListView mList = (ListView) findViewById(;

    final EditText et_search = (EditText) findViewById(;
    et_search.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            // Abstract Method of TextWatcher Interface.
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Abstract Method of TextWatcher Interface.
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // Abstract Method of TextWatcher Interface.
            Toast.makeText(getApplicationContext(), "Text changed", Toast.LENGTH_SHORT).show();



source to share

All Articles