General recommendation
1 - Override onCreateOption and inflate the menu
Note
It doesn't matter if you return true or call super
@Override public boolean onCreateOptionsMenu(Menu menu) {
2 - add the namespace to the menu.xml file.
xmlns:**yourapp**="http://schemas.android.com/apk/res-auto"
3 - set showAsAction to always or ifRoom
**yourapp**:showAsAction="ifRoom"
4 - if you use appcompat, make sure that your activity extends ActionBarActivity , you do not need to change any ActionBar value to be able to see your Option menu in the panel.
Finally, you will have something like [remember the user the correct namespace for yourapp ]
main.xml
<item android:id="@+id/action_settings" android:icon="@drawable/ic_action_settings" android:title="@string/action_settings" yourapp:showAsAction="ifRoom" />
in your activity
@Override public boolean onCreateOptionsMenu(Menu menu) {
source share