Android Actionbar items as three dots

Mustafa Chelik picture Mustafa Chelik · Dec 23, 2014 · Viewed 96.6k times · Source

I have a menu for my main activity (res/menu/main_menu.xml) and I want only one item on the Actionbar and the rest shall be hidden under three dots menu. Three dots menu

The problem is, I never see the three dots item on my actionbar. Why I can't see three dots item? How to force items to be hidden under it?

Note: I use minSdkVersion="14" and I test in AVD.

Answer

ban-geoengineering picture ban-geoengineering · Jan 30, 2015
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item android:id="@+id/menu_item_share"
        android:title="@string/share"
        android:icon="@android:drawable/ic_menu_share"
        app:showAsAction="ifRoom"
        android:actionProviderClass="android.widget.ShareActionProvider" />

    <item
        android:id="@+id/empty"
        android:title="@string/options"
        android:orderInCategory="101"
        app:showAsAction="always"
        android:icon="@drawable/baseline_more_vert_black">

        <menu>

            <item android:id="@+id/action_settings"
                android:icon="@android:drawable/ic_menu_preferences"
                app:showAsAction="ifRoom"
                android:title="@string/settings" />

            <item android:id="@+id/action_help"
                android:icon="@android:drawable/ic_menu_help"
                app:showAsAction="ifRoom"
                android:title="@string/help" />

        </menu>

    </item>

</menu>

You will need to add the baseline_more_vert_black icons to your res/drawable... folders once you've downloaded them from here.