Reputation: 146
Attached is a screenshot of search view implementation with listview activity working successfully. But, on any text search on the search view it shows the result with grayish toast like feature displaying what user has enter to filter the list. How do i remove it as it is blocking my list view display in the background?
Upvotes: 2
Views: 2200
Reputation: 1302
You have to place your adapter to a separate filter. The code looks something like this.
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
stringlist);
listView.setAdapter(adapter);
listView.setTextFilterEnabled(true);
Filter filter = adapter.getFilter();
And when listening for the text query, if your code look something like this
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
listView.clearTextFilter();
} else {
listView.setFilterText(newText.toString());
}
return true;
}
Just change it to this
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
filter.filter(null);
} else {
filter.filter(newText);
}
return true;
}
Upvotes: 5