This is how I do :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_menu, menu);
return true;
}
game_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:title="@string/new_game"/>
<item android:id="@+id/help"
android:title="@string/help" />
</menu>
But Eclipse keep telling me that menu is not a type… I tried to import R, clean my project and some others things i saw on the net.
I cant bypass this problem with that :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, Menu.FIRST + 1, 5, "??").setIcon(
android.R.drawable.ic_menu_delete);
menu.add(Menu.NONE, Menu.FIRST + 2, 2, "??").setIcon(
android.R.drawable.ic_menu_edit);
return true;
}
Thank you in advance and sorry for my spelling.
1 Answer