与搜索查看自定义搜索实现 [英] Custom search implementation with SearchView

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

问题描述

我要实现我的应用程序搜索,但我不希望使用一个单独的活动,以显示我的搜索结果。相反,我只希望使用显示的搜索查看下的suggestionslist。

I want to implement search in my app, but I don't want to use a separate Activity to display my search results. Instead, I only want to use the suggestionslist that displays beneath the SearchView.

我可以使用 setOnQueryTextListener 搜索查看,监听输入和搜索结果。但是,我怎么能这些结果添加到下面的列表中的搜索查看?让我们只是假设,我在寻找一个列表与LT;弦乐方式>

I can use setOnQueryTextListener on the SearchView, listen for input and search for results. But how can I add these results to the list below the SearchView? Let's just assume I'm searching in a List<String>.

推荐答案

您需要创建什么是的内容提供商
这样,你就可以添加自定义的结果您搜索查看,并添加自动完成功能,它只要用户输入的东西。

What you need to create is a Content Provider. In that way you can add custom results to your SearchView and add the autocomplete feature to it whenever the User inputs something.

如果我不记得了错误,在我的项目之一,我已经做了类似的东西,并没有花太长的时间。

If I don't remember incorrectly, in one of my projects I have done something similar, and it didn't take too long.

我相信这可能是有用的:<一href=\"http://stackoverflow.com/questions/11491515/turn-autocompletetextview-into-a-searchview-in-actionbar-instead\">Turn AutoCompleteTextView成一个ActionBar的搜索查看代替

I believe this could be helpful: Turn AutoCompleteTextView into a SearchView in ActionBar instead

和也是这个:<一href=\"http://stackoverflow.com/questions/9051573/searchmanager-adding-custom-suggestions\">SearchManager - 添加自定义的建议

希望这有助于。

ñ。

这篇关于与搜索查看自定义搜索实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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