14

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)

MSurrow
  • 1,183
  • 2
  • 9
  • 23
  • 3
    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 – MSurrow Jul 31 '11 at 12:49
  • 1
    If you found your own answer, you should post it as an answer and check it as accepted -- that will close your question and mark it as answered so other people can know there's no need for further help here. Answering your own question isn't considered taboo from a reputation standpoint either -- it doesnt' award you reputation, so it's fair game. – jcwenger Aug 02 '11 at 02:49
  • This solved my problem too, thanks very much for the follow up comment! – Ljdawson Oct 02 '11 at 17:30
  • I have the same problem, but for me the SUGGEST_COLUMN_TEXT_1 which is a column in the table is merely empty. Is that possible to map it somehow with a column which data I want to show in the suggestions OR I need to duplicate it (what I don't really want to do). – Eugene Sep 04 '12 at 22:25

1 Answers1

20

(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

MSurrow
  • 1,183
  • 2
  • 9
  • 23