Code example for SubMenu

Methods: add

0
     
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
               
        SubMenu subMenuFile = menu.addSubMenu("File");
        subMenuFile.add(Menu.NONE, NEW, Menu.NONE, "New");
        subMenuFile.add(Menu.NONE, OPEN, Menu.NONE, "Open");
        subMenuFile.add(Menu.NONE, SAVE, Menu.NONE, "Save");
         
        SubMenu subMenuEdit = menu.addSubMenu("Edit");
        subMenuEdit.add(Menu.NONE, CUT, Menu.NONE, "Cut");
        subMenuEdit.add(Menu.NONE, COPY, Menu.NONE, "Copy");
        subMenuEdit.add(Menu.NONE, PASTE, Menu.NONE, "Paste");
         
        menu.add(Menu.NONE, HELP, Menu.NONE, "Help");
         
        return super.onCreateOptionsMenu(menu);
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {