I have an issue when I try to set up an auto-complete search with a searchView on ActionBar.
I have a contentProvider which calls a webService on my own to get the suggestions. It return a cursor an the suggestion are correctly presented on the UI.
The problem is that nothing happen when I select one of these suggestions.
I'm not sure what to store in SUGGEST_COLUMN_INTENT_ACTION.
When reading the documentation, I understood that the onCreate method of my activity should be called again and that i could get the SUGGEST_COLUMN_INTENT_ACTION to know the context and get the SUGGEST_COLUMN_INTENT_DATA with intent.getData().
The onCreate is never called, no exception thrown, nothing happens...
What have I missed? Why nothing happens when I select a suggestion?
My searchable.xml :
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:searchSuggestAuthority="MyPackage.search_suggestion_provider"
android:searchSuggestIntentAction="android.intent.action.SEARCH" >
</searchable>
I just changed the setOnClickListener into setOnSuggestionListener and it worked...
Now, i get the position of the suggestion clicked but i need the id that my provider set in the cursor after the search is done. I've done it this way :
CursorAdapter c = searchView.getSuggestionsAdapter();
...
Cursor cur = c.getCursor();
cur.move(position);
String val = cur.getString(cur.getColumnIndex(BaseColumns._ID));
Is this the best way to do it ??
Due to the lack of good tutorial concerning the searchView in actionBar using contentProvider to asynchronously call a webService, i just try to make this work and i've got another question :
I never create any xml file that describe the list in which my suggestion are shown. How does it work ? Does it manage to create this listView based on the description of the curosr that my contentProvider return ??
Thx again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With