Search code examples
javaandroidxmlandroid-actionbaroverflow-menu

Overflow Menu doesn't show


I have a problem with my app...the overflow menu is invisible! I can physically tap on the top-right part of my phone and the menu items show, but the three dots do not show.

Here is my xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.android.example.MainActivity">

    <item
        android:orderInCategory="1"
        android:id="@+id/ic_home"
        android:title="Home"
        android:icon="@drawable/ic_home"
        app:showAsAction="withText"
        />

    <item
        android:orderInCategory="2"
        android:id="@+id/ic_chat"
        android:title="Forum"
        android:icon="@drawable/ic_chat"
        app:showAsAction="withText"
        />

    <item
        android:orderInCategory="3"
        android:id="@+id/ic_videos"
        android:icon="@drawable/ic_videos"
        android:title="Videos"
        app:showAsAction="withText"
        />

    <item
        android:orderInCategory="4"
        android:icon="@drawable/ic_timeline"
        android:id="@+id/ic_timeline"
        android:title="Timeline"
        app:showAsAction="withText"
        />

    <item
        android:icon="@drawable/ic_phone"
        android:id="@+id/ic_call"
        android:orderInCategory="5"
        android:title="Call"
        app:showAsAction="withText"
        />   

</menu>

Java code:

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    return super.onOptionsItemSelected(item);
}

I have tried other solutions on StackOverflow, but none of them seem to work. I have tried running the app on 2 phones, both with Android version > 4.4.

Update: I tried adding a navigation drawer to the app. Again, when I tap on the side where the drawer button is supposed to be, the menu shows up, but the button is not visible...

Update 2: I tried changing my theme settings in style.xml. When I made the windowActionBar to true instead of false and the windowNoTitle to false instead of true, both the drawer and the overflow menu show up. However, my toolbar shows up below the action bar like this.

How do add the menu buttons to the actual (white) toolbar?

Thanks in advance.


Solution

  • OK I found the answer:

    I got the default action bar back again and then created a layout resource file for a custom action bar.

    I added the design/specs of the desired bar in the custom action bar file and then set the action bar to the custom action bar file.

    It all worked out!