Android:是否可以在自定义搜索建议中插入永久选项?

标签 android search

我有一个 Android 应用程序,它具有使用 ContentProvider 查询支持我的应用程序的 SQLite 数据库的搜索功能。当用户输入他们的查询时,应用程序会提供自定义搜索建议,如 Android 文档中所述 here .

In addition to this I would like the search dialog to display a permanent option at the top of the custom search suggestions that when selected would perform a web search in the browser using the query (e.g., 'Search the web for xyz',或类似的)。其余建议将是来 self 的 ContentProvider 的标准搜索建议。

是否可以这样做,如果可以,怎么做?

编辑:

David 建议的解决方案有效。我做了这样的事情:

MatrixCursor cursor = new MatrixCursor(new String[] {BaseColumns._ID, 
      SearchManager.SUGGEST_COLUMN_TEXT_1});
cursor.addRow(new Object[] {0, "I'm always the top suggestion!"});
return new MergeCursor(new Cursor[] {cursor, mySearchSuggestionCursor});

最佳答案

使用 MergeCursor 可能是可行的,我自己没有尝试过,但看起来它是为这种情况设计的。

当然,您必须使用静态数据构建自己的游标。

关于Android:是否可以在自定义搜索建议中插入永久选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5732901/

相关文章:

android - 如何使用 native 代码和 Meteor 代码部署 Android 应用程序?

android - 共享库项目 Activity 的单一实例?

search - 我页面中的重复 URL,最佳解决方案?

Android 不显示特定屏幕的推送通知

java - Android 将按钮或 View 保留在应用程序内所有 Activity 的前面,而不使用 baseActivity

java - Joda 日期时间 DateTimeZone

javascript - 如何用 Javascript 实现客户端替换?

search - dijit.Tree搜索和刷新

c++ - 如何为自定义文件格式构建过滤器处理程序,以便可以通过 Windows 搜索搜索其内容?

javascript - 如果window.location以html结尾则执行javascript