SearchView does not show suggestions

2,359 views
Skip to first unread message

Maxxan

unread,
Nov 11, 2012, 2:37:25 PM11/11/12
to actionba...@googlegroups.com
I created a normal search dialog, which correctly shows the suggestions when I type, then I tried to switch to a SearchView, but then the suggestions stopped working. The search part still works though.

The CursorAdapter of SearchView is initialized, the suggestAuthority, suggestionIntentAction, SuggestionSelection are all set (and works with search dialog). SearchView.SearchAutoComplete text view get its suggestion adapter set in the SearchView.updateSearchAutoComplete. 

My content provider extends SearchRecentSuggestionsProvider, and the provider is created because I reach the ctor, but the query function is never called.

I've tested on both ICS and GB, using ABS 4.2. Am I missing something or doesn't search suggestions work?

onCreateOptionsMenu:
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
CursorAdapter adapter = searchView.getSuggestionsAdapter(); // Just for a test, it's not null
menu.add("Search")
.setIcon( R.drawable.abs__ic_search)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

Searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:hint="@string/search_hint"
    android:label="@string/app_name"
    android:searchSuggestAuthority="com.lostpixels.fieldservice.helpfunctions.SearchSuggestionsProvider"
    android:searchSuggestIntentAction="android.intent.action.VIEW"
    android:searchSuggestSelection=" ?"
    android:searchSuggestThreshold="0" 
    android:searchSuggestIntentData="content://com.lostpixels.fieldservice/person">
</searchable>

Maxxan

unread,
Nov 12, 2012, 5:33:11 PM11/12/12
to actionba...@googlegroups.com
Found the solution here https://github.com/JakeWharton/ActionBarSherlock/pull/653/files if anyone else have this problem.

Rory Smith

unread,
Jun 22, 2013, 11:14:28 AM6/22/13
to actionba...@googlegroups.com
Just want to say that for anyone else reading this, you need to download the dev branch, it wasn't in the latest master that I had previously downloaded
Reply all
Reply to author
Forward
0 new messages