如何实现android的搜索栏? [英] How can implement search bar in android?

查看:94
本文介绍了如何实现android的搜索栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android系统工作。我试图显示使用大学的ListView名称。

I am working in android. i am trying to display name of university using listView.

我的列表视图看起来像这样。

my list view is looking like this.

现在我想在这个列表视图的顶部添加一个搜索栏。如果我在搜索栏中preSS的 A ,然后这个列表视图应显示大学的所有名称是 A ,如果我再根据preSS其它字符开始必须显示的大学名称。

Now i want to add a search bar on the top of this list view. if i press A in search bar then this list view should display all the name of university start with A, if i press some other character then according university name must be displayed.

请告诉我如何可以实现这一点。是什么办法,使搜索栏的机器人。我已经看到了iPhone,它非常有效地工作在iPhone上。请帮助我如何可以使这个搜索栏?

Please tell me how can implement this. Is any way to make search bar in android. I have seen in iPhone, it works very efficiently in iPhone. Please help me how can make this search bar ?

感谢您提前...

推荐答案

这可能是很长的路要走。但是这仅仅是一个想法。

This may be the long way. but this is just an idea..

我认为你必须创建一个的EditText 的ListView 布局xml文件。内部活动,您有的EditText 监听textChange,然后可能你有你的 ListAdapter 根据输入的文本过滤由用户和的ListView 绑定。

I think you have to create a layout xml file with one EditText and ListView. Inside activity you have to listen for textChange in EditText and then probably you have to filter your ListAdapterbased on the text entered by the user and bind it with ListView.

在这里看到完整的示例:<一href=\"http://www.androidpeople.com/android-listview-searchbox-sort-items\">http://www.androidpeople.com/android-listview-searchbox-sort-items

See the complete example here : http://www.androidpeople.com/android-listview-searchbox-sort-items

这篇关于如何实现android的搜索栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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