All "Compat" items are used to provide backward compatibility. So in this case MenuItemCompat
supports action bar items for versions above 7 (instead of the normal 11). In the java code, if there is MenuItemCompat
, then in the xml too there must be a "Compat" item. Now, the "app" namespace supports these "Compat" items. So change the xml like this:
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/apmenu_search"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/srch"
app:showAsAction="ifRoom"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>