简体   繁体   中英

How to create Expandable MultiLevel Menus in android

I want to create a Expandable Multi-level (three level) menus and fill data dynamics. My data come from web server i want to fill data directly into menus and I also want First Level Menus and Second level is already open. I am new in android developing.Thanks in advance!

I give a reference below image:-

在此处输入图片说明

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_enter, menu);
    SubMenu submenu = menu.addSubMenu(0, Menu.NONE, Menu.NONE, "My Account");
    //submenu.add(0, 10, Menu.NONE, "My Profile");
    //submenu.add(0, 15, Menu.NONE, "Change Job");
    SubMenu submenu2 = submenu.addSubMenu(0, Menu.NONE, Menu.NONE, "Change Job");
    submenu2.add(0, 100, Menu.NONE, "Pilot");
    submenu2.add(0, 105, Menu.NONE, "Fligh Attendant");
    submenu2.add(0, 110, Menu.NONE, "Technical");
    //submenu.add(0, 20, Menu.NONE, "Log Out");
    return true;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM