开发者

Android: Is it possible to insert a permanent option into custom search suggestions?

I have an Android application that has a search function that uses a ContentProvider to query the SQLite database that backs my application. As the user types in their query the application provides custom search suggestions as described by the Android documentation 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', or similar). The rest of the suggestions would be the standard search suggestions from my ContentProvider.

Is it possible to do this, and if so, how?

Edit:

David's suggested solution works. I did something like this:

开发者_JS百科
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});


It might be possible with the MergeCursor, I haven't tried it myself but it looks like it was designed for this situation.

You'll have to construct your own cursor with the static data, of course.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜