Reputation: 1337
I am trying to create options menu in my Android program. I am using the following code to inflate options menu :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.optionsmenu, menu);
return true;
}
And my xml code is :
?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/Option1"
android:title="Option1"/>
<item
android:id="@+id/Option2"
android:title="Option2"/>
<item
android:id="@+id/Option3"
android:title="Option3"/>
</menu>
But with this code i am not able to show the options menu in my screen.
Also, i am using the code
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
to make the activity as full screen view. Does this code creates problem in inflating the menu?
Thanks in advance,
Timson
Upvotes: 3
Views: 6429
Reputation: 8161
Use this code:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
return true;
}
Upvotes: 0
Reputation: 68187
remove the line super.onCreateOptionsMenu(menu);
from your onCreateOptionMenu. You are actually already providing the menu before inflating it.
Upvotes: 2
Reputation: 2291
Don't call
super.onCreateOptionsMenu(menu);
as that will return a value before your code is executed.
Upvotes: 0
Reputation: 11230
Options menu shows up by pressing the Options Menu button at the bottom of the phone
Upvotes: 0