Android options menu not displaying

Android options menu not displaying

android menu not showing in toolbar
android context menu
floating context menu android
toolbar not showing android
android menu icon
overflow menu android
android menu bar
custom menu in android

I'm new to Android and I've been trying to add a simple add button as mentioned below

list_menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item 
        android:id="@+id/menu_insert"
        android:icon="@android:drawable/ic_menu_add"
        android:title="@string/menu_insert"              
    />     
</menu>

MyActivity.java

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.list_menu, menu);

        return true;  
    }

I read in Dummies series book that ic_menu_add is already there in resources and I don't need to add it, but when I run this code it does not display. I've tried to add a custom icon with same name still there is no button. Can someone help me with it please.


If you use a fragment then you need this in onCreate():

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
    }

Options Menu in Android app, By the time I decided to add the options menu into my application I had already had there a… Adapter to display a collection of objects in a CardView. because if it is not, you will not be able to use toolbar as an app bar. Android Options Menu not displaying. Ask Question Asked 8 years, 3 months ago. Active 3 years, 5 months ago. Viewed 3k times 4. 1. I am making a game for Android and


I was dealing with the same problem.. read some queries and documentation.. Hope this might help you.

Here's my XML file for a menu..

<item
    android:id="@+id/action_send_feedback"
    android:orderInCategory="100"
    android:showAsAction="always"
    android:title="@string/action_send_feedback"/>

<item 
    android:id="@+id/action_share_app"
    android:orderInCategory="100"
    android:showAsAction="ifRoom"
    android:title="@string/action_share_app"
    android:icon="@drawable/ic_action_share" />

<item
    android:id="@+id/action_rate_app"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_rate_app"/>

JAVA Code goes here..

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

For android phones which have option button (at the bottom of the phone) the menu item which are showAsAction="never" comes when the button is pressed.. or else they will be shown normally on the action bar options menu..

Ref: http://developer.android.com/guide/topics/ui/menus.html#options-menu

Overflow menu does not appear on screen, Anything below KitKat (4.4) will not show the overflow items if there is a Check out the commit message on the Android Platform where they now not find the options they were looking for, and had no idea that the menu  There is no way to control if your actionbar will show the three dot overflow menu or not in code. Well you can force it not to show by having no options menu for sure. And to be fair you can hack around this, more info at How to force use of overflow menu on devices with menu button. The dots showing or not depends on the device you're testing on. Devices with a menu button will NOT SHOW the three dot icon on the actionbar since users can use the menu button on the device.


It is not required to call super() method. Try replacing your onCreateOptionsMenu for that:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_menu, menu);
    return true;
}

Menus, Not cool. In short, to fix this problem I just had to add this setting to my menu item definitions: android:showAsAction="ifRoom". An Options Menu may be hidden, but work. You can check this by long pressing the hardware button "Recent Apps". In addition to the mentioned reasons for the hidden menu, there may be a theme without an action bar specified in the AndroidManifest.xml <application android:theme="@style/Theme.Design.NoActionBar" </application>


For me, I had to add the following code to the activity xml:

 <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/AppTheme"
        app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
        app:title="@string/app_name"
        app:titleMarginStart="24dp"
        app:titleTextColor="@android:color/white" />

Then to the activity.java: onCreate

Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

And

    @Override
public boolean onCreateOptionsMenu(Menu menu) {
    //super.onCreateOptionsMenu(menu);
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

And fragment onCreate:

 setHasOptionsMenu(true);

How to get Android ActionBar menu item icons to show (without , The reason probably is that the items in the Overflow menu are supposed to be show the icon also by setting android:showAsAction="always" in the menu xml. As a developer, you could use the Menu button to display whatever options  Put log statements in the code to see if the method is not being called or if the menu is not being amended by your code. Also ensure you are calling setHasOptionsMenu (boolean) in onCreate (Bundle) to notify the fragment that it should participate in options menu handling.


If you set your TargetSDK in the manifest to 5, the icon will show up.

If you are targeting a newer Android SDK (3.0 and up) the action bar takes over the menu and by default doesn't display icons.

You can try this:

How to show icons in ActionBar overflow menu?

Why does Android not show an icon in the overflow menu?, In android options menu is used to implement an actions that have a global impact in both activity or fragment, then those items will be combined and display in UI. In case if you are not aware of creating an app in android studio check this  Options menu disappeared from File menu in Office 365 Excel, Word, PowerPoint When I click on "File" in Office 365 Excel, Word or PowerPoint, the "Options" menu is missing. The only way I can get to it is to search for "Options" in the search box on the main screen top tab.


Android Options Menu with Examples, options menu are displayed when the user pushes the menu button on If there's not enough room, the item appears in the overflow menu. If your toolbar is black color and the menu text is also in black color, you can't really see it. Even overflow menu icon was also black :D (It happened in my case). Further dismay- if there are only one or two menu options, even menu button does not seem to work (because menu is already present in toolbar) – Vinay Bhargav Apr 27 '16 at 12:48


Android Action Bar from the Options Menu, The option menu is displayed if the user presses In case of the options menu, the user may not  In case, if we define items for the options menu in both activity or fragment, then those items will be combined and display in UI. Create Android Options Menu in XML File. In android, to define options menu, we need to create a new folder menu inside of our project resource directory (res/menu/) and add a new XML (menu_example) file to build the menu.


Using the Android Toolbar (ActionBar) - Tutorial, Option;. import android.app.Activity;. import android.os.Bundle; Running the app doesn't cause the options menu to be displayed. Pressing