views:

48

answers:

1

Hi,

I have managed to create a menu with four options. I want to create four sub menus of same style for each option.

In my infinite nooby-ness I have created four classes for the sub menus but I cannot figure out how to move between the menus(Classes). For instance I have four options Prem, Champ, L1, L2, I have created the Prem sub menu but how do I get the program to move to this class(SubMenu) when the Prem option is selected, and how do I get it to move back.

Many Thanks in Advance!!!!

A: 

If you haven't already, check out the Dev guide entries for the Menu resource and creating a menu.

basically, if you're using eclipse you just have to add an Android XML file and specify the the content is a menu. You can then add submenus and the system takes care of navigation for you. (You will need to load the menu using the MenuInflater function)

You should end up with your menu xml looking like this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <item android:id="@+id/menu_item1" android:title="@string/menu_item1"></item>
        <item android:title="@string/menu_submenu" android:id="@+id/menu_submenu">
        <menu>
            <item android:id="@+id/menu_sub1" android:title="@string/menu_sub1"></item>
            <item android:id="@+id/menu_sub2" android:title="@string/menu_sub2"></item>
            <item android:id="@+id/menu_sub3" android:title="@string/menu_sub3"></item>             
        </group>
    </menu>
</item>

FixerMark