After hours of trying to get a support SearchView in my support Toolbar to work correctly (it shows up, shows the hint text but refuses to accept text), I have to turn to you.
I have Googled for hours, read A LOT of answers here and in other sites, checked out a lot of documentation and a specific blog post dealing with the subject but I just can't isolate the issue.
As I have said, I am using the support versions of SearchView and Toolbar and also MenuItemCompat. Also, ActionBarActivity. I made sure that I followed all the steps religiously (this blog post had a lot to say on the subject, even mistakes in the official documentation).
I have set the AndroidManifest.xml file correctly, I have a searchable.xml which, as far as I understand, is referenced correctly (I mean, the hint text shows up normally in the SearchView field), I have a search result activity with an android.intent.action.SEARCH intent filter set in the manifest.
Still nothing. I'm honestly stumped here.
Here's the onCreateOptionsMenu() of the SearchView-hosting activity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem search = menu.findItem(R.id.search);
searchView = (SearchView) MenuItemCompat.getActionView(search);
SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
return true;
}
And here is searchable.xml in res/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/search_title" >
</searchable>
Finally, here is the menu.xml file in res/menu:
<item
android:id="@+id/search"
android:icon="@drawable/ic_search_white_18dp"
android:title="@string/search_title"
myappname:actionViewClass="android.support.v7.widget.SearchView"
myappname:showAsAction="ifRoom|collapseActionView"/>
(obviously myappname replaces my real app name here).
Weirdly, voice search works perfectly normal after I add
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
in searchable.xml. It even sends the recognised phrase in the intent to the search results activity. The only problem is that I simply can't input text in the text field - there's not even a cursor blinking there. Attempts to do something like searchView.requestFocus() have no result.