I need to inflate a custom menu in a snippet.
I have only one menu item. But the icon is not displayed.
Can someone say what's wrong with my code
My menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" >
<item
android:id="@+id/search"
android:icon="@android:drawable/ic_search_category_default"
app:showAsAction="always"
android:title="Search"/></menu>
And I set onCreateView ()
setHasOptionsMenu(true);
getActivity().invalidateOptionsMenu();
And inflating the menu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.menu, menu);
}
The resulting screen attached below. I need to have a search icon instead of a menu overflow icon.

source
share