Can't get android.support.v7.widget.SearchView file to receive text

After several hours of trying to get SearchView support in my support toolbar for proper operation (it displays, displays hint text, but does not accept text), I should contact you.

I have Google in a few hours, read a lot of answers here and on other sites, checked a lot of documentation and a separate blog post on the topic, but I just can not isolate the problem.

As I said, I use SearchView and Toolbar support versions, as well as MenuItemCompat. In addition, ActionBarActivity. I made sure that I followed all the steps religiously ( this blog post could say a lot about this, even errors in the official documentation).

I installed the AndroidManifest.xml file correctly, I have searchable.xml, which, as I understand it, is correctly referenced (I mean that the help text is displayed normally in the SearchView field), I have a search result using the android intent filter. intent.action.SEARCH set in the manifest.

Still nothing. I'm honestly a dead end 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"/>

(, myappname ).

,

android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"

searchable.xml. . , - . - searchView.requestFocus() .

+4
1

8 , . , , .

, EditText SearchView : , , , , , . , EditText SearchView, android.R.id EditText.

. EditText SearchView :

EditText searchField = (EditText) 
searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);

EditText:

searchField.requestFocus();

... SearchView , !

: onPause(), , EditText. :

invalidateOptionsMenu();

... onResume(), .

, : , ( Android, ), EditText SearchView. , Activity, , , , .

+2

All Articles