而Android的打字搜索列表 [英] Android search list while typing

查看:165
本文介绍了而Android的打字搜索列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能建立在哪里,而我打字,结果显示在的ListView 中,我在寻找一个搜索栏?

How can I build a search bar where while I'm typing the results are shown in the ListView in which I'm searching?

例如,我有一个列表视图20字符串。我preSS搜索键,并出现了吧。我希望当我输入3个字以上的搜索开始运行显示的结果列表视图(作为一个过滤器:只显示所匹配的是我输入列表中的字符串)

For example, I have a list view with 20 strings. I press the search key and appears the bar. I want when I type 3 words or more the search starts running showing the results in the list view (as a filter: only shows the strings in the list that matching what I type)

推荐答案

您无法与搜索栏做到这一点。但列表视图有一个可能性,<一个href="http://developer.android.com/reference/android/widget/AbsListView.html#setTextFilterEnabled%28boolean%29">filter关键pressed ,就像是在联系人完成。用户只需开始输入和列表被过滤,然后。过滤是不是真的喜欢搜索。如果列表中包含单词foo的地方,你的类型OO foo将被过滤掉,但如果你键入FO它会留即使列表项是通话酒吧FOO。

You can't do this with the search bar. But the listview has a possibility to filter on key pressed, like it is done in the contacts. The user simply starts typing and the list gets filtered then. Filtering is not really like searching. If you list contains the word foo somewhere and you type oo foo will be filtered out, but if you type fo it will stay even if the list item is call bar foo.

您只需要启用它:

ListView lv = getListView();
lv.setTextFilterEnabled(true);

我不知道如何做到这一点,如果你没有硬件键盘。我使用的机器人,并开始启动类型列表进行过滤和只显示匹配的结果。

I don't know how this is done if you don't have a hardware keyboard. I'm using the droid and starting to type starts the list to filter and to show only matching results.

这篇关于而Android的打字搜索列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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