I am going to inflate
a menu in my first Activity
.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
The R.menu.main:
<item
android:id="@+id/action_serach"
android:title="Search"
android:orderInCategory="100"
android:icon="@drawable/ic_search"
app:showAsAction="ifRoom" />
It doesn't work, but it inflates the another XML file named R.menu.menu_home
.
The R.menu.menu_home:
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_star"
android:title="Search"
android:orderInCategory="100"
android:icon="@drawable/ic_star_half"
app:showAsAction="ifRoom"
/>
</menu>
But in my second Activity
, it works, whether it's R.menu.main
or R.menu.menu_home
.
why?