关于 Android 搜索的建议?
我可以使用 onSearchRequested() 方法在我的应用程序上实现 QSB。我的表中有 4 列。当我输入 QSB 时。它会在建议窗口中给出一些建议。怎么办?可搜索字典示例显示了用于检索建议的字典提供程序类。但没有插入任何数据。然后他们如何获得建议。您能解释一下我们必须遵循的步骤或教程吗?最感谢的是示例代码。
i can implement the QSB on my app using onSearchRequested() method.i have 4 column in my table. when i was type in the QSB. it will give some suggestions on the Suggestion window. how to do that? searchable dictionary example shows the dictionary provider class to retrive the suggestions. but on that no data inserted. then how they getting the suggestions. can you explain me what are the steps we have to follow or tutorials, sample codes are most thankful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在可搜索词典示例中,建议是由
DictionaryProvider
中的getSuggestions()
方法创建的。当您在搜索框中键入内容时,搜索框架将查询内容提供程序(我相信在每次击键之后)并显示光标返回的结果。您还可以选择实现 SearchRecentSuggestionsProvider,而不是使用成熟的内容提供程序。但是,使用此方法,特定搜索生成的搜索建议仅在后续搜索中显示。因此,它的功能虽然不那么齐全,但实现起来的工作量却较少。
以下是关于搜索的概述,以及SearchManager。
In the Searchable Dictionary example, the suggestions are created by the
getSuggestions()
method inDictionaryProvider
. As you type in the search box, the search framework will query the content provider (after each keystroke, I believe) and display the results returned by the cursor.Instead of going with the full-blown content provider, you could also choose to implement SearchRecentSuggestionsProvider. However, with this method, your search suggestions generated by a particular search are only shown on subsequent searches. So, it's not as full-featured, but less work to implement.
Here's an overview on search, and more detailed information in SearchManager.