Android Nested Menu (Sub Menu)

Jul 25, 2018

Menu XML Resource

<?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/action_share"
        android:title="Share"
        android:icon="@drawable/ic_share_black_24dp"
        app:iconTint="@android:color/white"
        app:showAsAction="ifRoom">

        <menu>
            <item
                android:id="@+id/action_share_photo"
                android:title="Share Photo"
                />

            <item
                android:id="@+id/action_share_photo_with_text"
                android:title="Share Photo with Text"
                />

            <item
                android:id="@+id/action_share_web_link"
                android:title="Share Web Link"
                />
        </menu>
    </item>

    <item
        android:id="@+id/action_delete"
        android:title="Delete"
        app:showAsAction="never" />
</menu>

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.