过滤文本显示在搜索查看不删除 [英] Filter Text Display in SearchView not removing

查看:139
本文介绍了过滤文本显示在搜索查看不删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附件是搜索视图实现与ListView的活动成功合作的截图。但是,对搜索视图的任何文本搜索它显示像功能显示哪些用户输入过滤列表呈灰敬酒的结果。如何,因为它阻止我的列表视图显示在后台我删除它?

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?

推荐答案

您有您的适配器放置到一个单独的过滤器。在code看起来是这样的。

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();

和文本查询收听时,如果你的code是这个样子

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;
}

就改成这样

@Override
public boolean onQueryTextChange(String newText) {
   if (TextUtils.isEmpty(newText)) {
        filter.filter(null);
   } else {
        filter.filter(newText);
   }
   return true;
}

这篇关于过滤文本显示在搜索查看不删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆