Per the Defining Menus via XML Guide:
You can add a submenu to an item in any menu (except a submenu) by adding a
<menu>
element as the child of an<item>
. Submenus are useful when your application has a lot of functions that can be organized into topics, like items in a PC application's menu bar (File, Edit, View, etc.).
They give an example XML of:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/file"
android:title="@string/file" >
<!-- "file" submenu -->
<menu>
<item android:id="@+id/create_new"
android:title="@string/create_new" />
<item android:id="@+id/open"
android:title="@string/open" />
</menu>
</item>
</menu>
In this case, your onOptionsItemSelected
would look for create_new
and open
actions (and the file
item would be handled by the menu itself).