Search Suggestion results displayed as blank/no text

非 Y 不嫁゛ 提交于 2019-12-05 13:15:55

问题


I have included a Search Dialog in my Activity which works fine. However adding Search Suggestions gives me a little problem: The search suggestion entries are "empty".

I can see my content provider gets called (query(..)) and I return a MatrixCursor with several rows. The suggestions list also shows with (clickable) entries -- but are all blank. Blank as if the string I returned for SUGGEST_COLUMN_TEXT_1 and SUGGEST_COLUMN_TEXT_2 where an empty string.

The columns I use in the MatrixCursor are:

String[] columnNames = {"_ID", "SUGGEST_COLUMN_TEXT_1", "SUGGEST_COLUMN_TEXT_2", "SUGGEST_COLUMN_INTENT_EXTRA_DATA"};

I did try with just the _ID and SUGGEST_COLUMN_TEXT_1 column but same result.

EDIT: And I tried returning a simple "test" string as SUGGEST_COLUMN_TEXT_1 instead of something from my data.

I'm note quite sure what code is relevant here, so please ask for whatever may be needed to figure this out.

I have no idea for where to look for this bug, and my Google-Fu has failed me.

Thanks

(I would like to have added an 'android-search-suggestion' tag, but I'm newguy so it seems I cant)


回答1:


(Thank you, Jcwenger for teaching the new guy :-)

The solution, from my comment above:

Found it. Use SearchManager.SUGGEST_COLUMN_TEXT_1 instead of "SUGGEST_COLUMN_TEXT_1".. (Same for the rest).The String SearchManager.SUGGEST_COLUMN_TEXT_1 maps to "suggest_text_1": http://developer.android.com/reference/android/app/SearchManager.html#SUGGEST_COLUMN_TEXT_1



来源:https://stackoverflow.com/questions/6889285/search-suggestion-results-displayed-as-blank-no-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!