android.widget.SearchView cannot be cast to android.support.v7.widget.SearchView

In the menu.xml your <item></item> has to be

<item
  android:id="@+id/action_search"
  android:icon="@drawable/ic_action_search"
  android:title="@string/action_search"
  android:showAsAction="collapseActionView|ifRoom"
  android:actionViewClass="android.support.v7.widget.SearchView" />

with that change in the last line


you should use these imports instead of using the support library imports

import android.app.SearchManager;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;

Just to keep in mind that the minimum SDK is marked as 14

Tags:

Android