Android SearchView setOnQueryTextListener not working?
<p>I am making a search option in the Actionbar of my application. I have the Search icon displaying and it collapes when i click it and I can type in queries.</p>

<p>When my application starts, the onCreateOptionsMenu gets called. I print a test statement to verify it and then inside that function I set an setOnQueryTextListener. But it doesn't work. I tried testing it by printing when ever I type something in the searchview but it doesn't work. Please help me find the bug. Also there is an Listener for when it expands and collapes and that doesn't work either.</p>

<pre><code>@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.manageusersmenu, menu);
    MenuItem item = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);

    Log.i("onCreateOptionsMenu: ", "I made it in here");

    MenuItemCompat.setOnActionExpandListener(item,
            new MenuItemCompat.OnActionExpandListener() {
                @Override
                public boolean onMenuItemActionCollapse(MenuItem item) {
                     mAdapter.setFilter(mUsers);
                    Log.i("ActionCollapse: ", "Collapsed");
                    return true;
                }
                @Override
                public boolean onMenuItemActionExpand(MenuItem item) {
                    Log.i("ActionExpand: ", "Expanded");
                    return true;
                }
            });

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            Log.i("on query: ", newText);
            List&lt;User&gt; filteredModelList = filter(mUsers, newText);
            for (int i = 0; i &lt; filteredModelList.size(); i++) {
                Log.i("user, ", filteredModelList.get(i).getFName().toString());
            }
            mAdapter.setFilter(filteredModelList);
            return true;
        }

        private List&lt;User&gt; filter(List&lt;User&gt; users, String query) {
            query = query.toLowerCase();

            final List&lt;User&gt; filteredModelList = new ArrayList&lt;&gt;();
            for (User u : users) {
                final String text = u.getFName().toLowerCase();
                if (text.contains(query)) {
                    filteredModelList.add(u);
                }
            }
            return filteredModelList;
        }
    });

}
</code></pre>

<p>Menu file</p>

<pre><code>&lt;menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    &gt;

    &lt;!-- "Mark Favorite", should appear as action button if possible --&gt;
    &lt;item
        android:id="@+id/add_new_user"
        android:icon="@drawable/ic_action_name"
        android:title="@string/add_new_user"
        app:showAsAction="ifRoom"/&gt;

    &lt;item
        android:id="@+id/action_search"
        android:icon="@android:drawable/ic_menu_search"
        android:title="action_search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="always|collapseActionView" /&gt;

&lt;/menu&gt;
</code></pre>