如何从列表视图过滤器中删除弹出文本? [英] How do I remove popup text from listview filter?

查看:10
本文介绍了如何从列表视图过滤器中删除弹出文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ListView 上使用文本过滤器,我想去掉显示过滤器文本内容的弹出视图.有什么办法可以去掉这个视图吗?

I'm using a text filter on a ListView and I'd like to get rid of the popup view that shows what the filter text is. Is there any way to remove this view?

一些示例代码:

    ArrayList<String> buildingNames = new ArrayList<String>();
    ListView list = (ListView)findViewById(R.id.list);

    list.setAdapter(new ArrayAdapter<String>(this, R.layout.menu_item, buildingNames));
    list.setTextFilterEnabled(true);

    list.setFilterText("test_filter");

当我设置过滤器文本时,ListView 底部会弹出一个非常丑陋的视图,显示当前过滤器文本是什么:

When I set the filter text, a really ugly view pops up at the bottom of the ListView that shows what the current filter text is:

推荐答案

我在这里找到了答案:http://markmail.org/message/7uju6bmmaswag2lu:

I found the answer here: http://markmail.org/message/7uju6bmmaswag2lu:

通过调用 setTextFilterEnabled() 您确实请求此弹出窗口.如果你不想要它,禁用文本过滤.这是一个互动功能对于用户.它并不意味着以编程方式使用.如果你想要以编程方式过滤您的适配器,请在您的直接适配器(如果您的适配器支持过滤.)

By calling setTextFilterEnabled() you do request this popup. If you don't want it, disable text filtering. This is an interactive feature for the user. It is not meant to be used programatically. If you want to programatically filter your adapter, call getFilter() on your adapter directly (if your adapter supports filtering.)

罗马人

因此,您需要像这样直接使用过滤器,而不是使用 setTextFilterEnabled:

So rather than using setTextFilterEnabled you need to work with the filter directly like so:

CustomAdapter customAdapter = (customAdapter)myListView.getAdapter();
Filter filter = customAdapter .getFilter();
filter.filter("search string");

这篇关于如何从列表视图过滤器中删除弹出文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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