The app runs fine. On devices with hard options menu button the menu shows up, so i know it works. On some devices it shows the overflow button at the top-right.
I my test case the device is Asus Zenphone 5 there is no hard button, i dont get a overflow button either. But when i run the showOptionsMenu() command from a button click it displays the options menu and all related events work no issues.
Menu - Xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/select" android:title="Select" android:showAsAction="never"></item>
<item android:id="@+id/add_kid" android:title="Add" android:showAsAction="never"></item>
</menu>
onCreate & onPrepare
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.menu1, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
if(!getCheckInStatus())
{
menu.setGroupVisible(R.id.group1,false);
}
else
{
menu.setGroupVisible(R.id.group1,true);
}
return super.onPrepareOptionsMenu(menu);
}
Manifest values for the Activity
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
.....
<activity
android:name="com.my.package.MyActivity"
android:configChanges="orientation|keyboard"
android:label="@string/app_name"
android:launchMode="singleInstance"
>
</activity>
I would really appreciate any help on this matter.
in your menu.xml you just use showAsAction as never which represent Never place this item in the Action Bar. please refer the link for more info
set
android:showAsAction="ifRoom"
in menu.xml, the button would show.Try like this. This works for me..
I used to have same problem in few of my projects. I followed the steps given below which worked for me 1. extends your activity to ActionBarActivity
call the following code in onCreate method
As i commented in vinay's answer , the reason was that i was debugging an old program written by some one else. It seems all were Activities , but i had changed the target and compile-with to 22. Once i changed the Activity to ActionBarActivity the overflow appeared on the devices with soft menu button. While those with hard options menu button did not display it.