【发布时间】:2011-04-20 15:32:44
【问题描述】:
我有一个具有搜索功能的 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',或类似)。其余的建议将是来自我的 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});
【问题讨论】: