Search code examples
androidandroid-listviewbaseadaptersearchviewandroid-filterable

Search View and Filterable: Showing a bar with searched text


I am using SearchView with ListView and implementing Filterable to filter record. Its working fine except two problems.

The problems are:

  1. When I write something in SearchView a black bar with searched text showing.
  2. An arrow (>) symbol is also visible on right edge of SearchView.

I want to remove both. How can I remove them?

Here is the image of the problems. enter image description here


Solution

  • Try this for popup

    disable TextFilterEnabled on your ListView

    yourListView.setTextFilterEnabled(false);
    

    and filter your data like this:

    android.widget.Filter filter = yourListAdapter.getFilter();
    

    Also Add:

    @Override
            public boolean onQueryTextChange(String newText) {
                System.out.println("tap");
                yourAdapter ca = (yourAdapter)listview.getAdapter();
    
                if (TextUtils.isEmpty(newText)) {
    
                   listview.clearTextFilter();  
    
                } else {
    
                    filter.filter(newText);
    
    
                }
                return true;
            }