If you want your suggestions to show up in landscape, you need to do one of the following:
- Add
SUGGEST_COLUMN_QUERY
to your suggestion results
- Add
android:searchMode="queryRewriteFromText"
or ``android:searchMode="queryRewriteFromData"to your
searchable.xml`
However, I think for suggestions it's nicer to just show the normal popup instead of a fullscreen keyboard. You can achieve this by adding android:imeOptions="flagNoExtractUi"
to your searchable.xml
.
And that's all. If you're curious, here's how I tracked this down:
Hierarchy Viewer will tell you that the search dialog is implemented by SearchDialog
, which uses an AutoCompleteTextView
for the completion text view. Its buildDropDown()
function calls Filter.convertResultToString()
(through convertSelectionToString()
) on the items returned by the AutoCompleteTextView
's mAdapter.getItem()
and then passes these on to InputMethodManager.displayCompletions()
(which is responsible for the suggestions you want).
In the case of SearchDialog
, the adapter is a SuggestionsAdapter
. This is a subclass of CursorAdapter
, whose getFilter()
method returns a CursorFilter
class, which implements convertResultToString()
by just delegating to convertToString()
on the adapter class. SuggestionsAdapter
finally implements this method as follows:
public CharSequence convertToString(Cursor cursor) {
if (cursor == null) {
return null;
}
String query = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_QUERY);
if (query != null) {
return query;
}
if (mSearchable.shouldRewriteQueryFromData()) {
String data = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_INTENT_DATA);
if (data != null) {
return data;
}
}
if (mSearchable.shouldRewriteQueryFromText()) {
String text1 = getColumnString(cursor, SearchManager.SUGGEST_COLUMN_TEXT_1);
if (text1 != null) {
return text1;
}
}
return null;
}
…which results in the recommendations in the first paragraph above.