Example usage for android.view Menu addSubMenu

List of usage examples for android.view Menu addSubMenu

Introduction

In this page you can find the example usage for android.view Menu addSubMenu.

Prototype

SubMenu addSubMenu(@StringRes final int titleRes);

Source Link

Document

Add a new sub-menu to the menu.

Usage

From source file:net.pocketmine.server.HomeActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem log = menu.add(0, CONSOLE_CODE, 0, R.string.title_activity_log).setIcon(R.drawable.hardware_dock);
    MenuItemCompat.setShowAsAction(log, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SubMenu sub = menu.addSubMenu(getString(R.string.abs_settings));
    /**//w ww. j  av  a2  s.  co  m
     * Set Icon for Submenu
     */
    sub.setIcon(R.drawable.action_settings);
    /**
     * Build navigation for submenu
     */
    sub.add(0, VERSION_MANAGER_CODE, 0, getString(R.string.abs_version_manager));
    sub.add(0, PROPERTIES_EDITOR_CODE, 0, getString(R.string.abs_properties_editor));
    sub.add(0, PLUGINS_CODE, 0, getString(R.string.abs_plugins));
    sub.add(0, FORCE_CLOSE_CODE, 0, getString(R.string.abs_force_close));
    sub.add(0, ABOUT_US_CODE, 0, getString(R.string.abs_about));
    sub.add(0, REINSTALL_PHP_CODE, 0, getString(R.string.php_reinstall));
    MenuItem subgrp = sub.getItem();
    MenuItemCompat.setShowAsAction(subgrp, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;
}

From source file:pw.dedominic.airc.App.java

public void recreateDrawerItems() {
    Menu menu = navView.getMenu();
    menu.clear();//from w w  w  . j av  a  2 s.  co m
    SubMenu smenu = menu.addSubMenu("Servers");
    for (Server server : dao) {
        if (server.equals(selectedServer))
            smenu.add(server.getTitle()).setIcon(R.drawable.green_circle);
        else
            smenu.add(server.getTitle());
    }
    smenu = menu.addSubMenu("Actions");
    String[] actions = getResources().getStringArray(R.array.nav_items);
    if (actions.length != 5)
        throw new RuntimeException("LOLWUT?");
    smenu.add(actions[0]).setIcon(android.R.drawable.ic_input_add);
    smenu.add(actions[1]).setIcon(android.R.drawable.ic_menu_edit);
    smenu.add(actions[2]).setIcon(android.R.drawable.ic_menu_delete);
    smenu.add(actions[3]).setIcon(android.R.drawable.ic_menu_preferences);
    smenu.add(actions[4]);

}

From source file:th.in.ffc.person.visit.VisitDiagActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.edit_activity, menu);
    String[] diagType = getResources().getStringArray(R.array.diag_DX);
    SubMenu sub = menu.addSubMenu(R.string.add);
    sub.add(0, 2, 0, diagType[2]);// ww  w  .j a  va  2s .  c o m
    sub.add(0, 4, 0, diagType[4]);
    sub.add(0, 5, 0, diagType[5]);
    sub.setIcon(R.drawable.ic_action_add);
    sub.getItem().setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;
}

From source file:com.landenlabs.all_devtool.NetFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    m_menu = menu.addSubMenu("Sys Options");
    inflater.inflate(R.menu.sys_menu, m_menu);
    // m_menu.findItem(m_sortBy).setChecked(true);
}

From source file:org.geometerplus.android.fbreader.FBReader.java

private Menu addSubmenu(Menu menu, String id) {
    return menu.addSubMenu(ZLResource.resource("menu").getResource(id).getValue());
}

From source file:com.landenlabs.all_devtool.GpsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    m_menu = menu.addSubMenu("GPS Settings");
    inflater.inflate(R.menu.gps_menu, m_menu);
    m_menu.findItem(R.id.clock_12).setChecked(true);
}

From source file:com.grarak.kerneladiutor.activities.NavigationActivity.java

private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();/*from   w  w  w  .  j a  va  2  s  .  c o  m*/
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED && Prefs.getBoolean("section_icons", false, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable
                                : R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled", true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) : lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}

From source file:org.medcare.Dicom.DicomActivity.java

/**
 * Create some menu options./*  www .j  av a2  s. c  o m*/
 * 
 * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // SubMenu fileMenu = menu.addSubMenu("Fichier");
    SubMenu editMenu = menu.addSubMenu("Processing");
    // fileMenu.add(FILE, Quitter_MENU_ITEM, 1, "Quitter");
    SubMenu ctMenu = menu.addSubMenu("CT");
    SubMenu mrMenu = menu.addSubMenu("MR");
    SubMenu otMenu = menu.addSubMenu("OT");
    SubMenu usMenu = menu.addSubMenu("US");
    SubMenu divMenu = menu.addSubMenu("AUTRES");
    SubMenu collabMenu = menu.addSubMenu("COLLAB");

    ctMenu.add(CT, CT_MONO2_12_lomb_an2, 0, "CT-MONO2-12-lomb-an2");
    ctMenu.add(CT, CT_MONO2_16_brain, 1, "CT-MONO2-16-brain");
    ctMenu.add(CT, CT_MONO2_16_chest, 2, "CT-MONO2-16-chest");
    ctMenu.add(CT, CT_MONO2_16_ort, 3, "CT-MONO2-16-ort");
    ctMenu.add(CT, CT_MONO2_8_abdo, 4, "CT-MONO2-8-abdo");
    ctMenu.add(CT, CT_MONO2_16_ankle, 5, "CT-MONO2-16-ankle");

    mrMenu.add(MR, MR_MONO2_12_an2, 0, "MR-MONO2-12-an2");
    mrMenu.add(MR, MR_MONO2_12_angio_an1, 1, "MR-MONO2-12-angio-an1");
    mrMenu.add(MR, MR_MONO2_12_shoulder, 2, "MR-MONO2-12-shoulder");
    mrMenu.add(MR, MR_MONO2_16_head, 3, "MR-MONO2-16-head");
    mrMenu.add(MR, MR_MONO2_16_knee, 4, "MR-MONO2-16-knee");
    mrMenu.add(MR, MR_MONO2_8_16x_heart, 5, "MR-MONO2-8-16x-heart");

    otMenu.add(OT, OT_MONO2_8_a7, 0, "OT-MONO2-8-a7");
    otMenu.add(OT, OT_MONO2_8_colon, 1, "OT-MONO2-8-colon");
    otMenu.add(OT, OT_MONO2_8_hip, 2, "OT-MONO2-8-hip");
    otMenu.add(OT, OT_PAL_8_face, 3, "OT-PAL-8-face");

    usMenu.add(US, US_MONO2_8_8x_execho, 0, "US-MONO2-8-8x-execho");
    usMenu.add(US, US_PAL_8_10x_echo, 1, "US-PAL-8-10x-echo");
    usMenu.add(US, US_RGB_8_epicard, 2, "US-RGB-8-epicard");

    divMenu.add(DIV, CR_MONO1_10_chest, 0, "CR_MONO1_10_chest");
    divMenu.add(DIV, R_MONO1_10_chest, 1, "R-MONO1-10-chest");
    divMenu.add(DIV, NM_MONO2_16_13x_heart, 2, "NM-MONO2-16-13x-heart");
    divMenu.add(DIV, XA_MONO2_8_12x_catheter, 3, "XA-MONO2-8-12x-catheter");

    collabMenu.add(COLLAB, SET_CONNECT, 3, getString(R.string.main_menu_set_connect));
    collabMenu.add(COLLAB, QUIT, 4, getString(R.string.main_menu_quit));

    editMenu.add(EDIT, initialise_MENU_ITEM, 0, "reInit");
    editMenu.add(EDIT, zoomIn_MENU_ITEM, 1, "zoomIn");
    editMenu.add(EDIT, zoomOut_MENU_ITEM, 2, "zoomOut");
    editMenu.add(EDIT, multiseuillage_MENU_ITEM, 3, "thresholding");
    editMenu.add(EDIT, binarisation_MENU_ITEM, 4, "binarization");
    editMenu.add(EDIT, median_MENU_ITEM, 5, "median");
    editMenu.add(EDIT, inversion_MENU_ITEM, 6, "inversion");
    editMenu.add(EDIT, gradient_MENU_ITEM, 7, "gradient");
    editMenu.add(EDIT, segmentation_MENU_ITEM, 8, "segmentation");
    return super.onCreateOptionsMenu(menu);
}

From source file:org.csp.everyaware.offline.Map.java

/*************************** OPTION MENU ***************************************************/

public boolean onCreateOptionsMenu(Menu menu) {
    String[] menuItems = getResources().getStringArray(R.array.map_optionmenu);

    SubMenu mapSubMenu = menu.addSubMenu("Map Modes").setIcon(android.R.drawable.ic_menu_mapmode);

    mapSubMenu.add(1, Menu.FIRST, Menu.FIRST, "Hybrid").setCheckable(false);
    mapSubMenu.add(1, Menu.FIRST + 1, Menu.FIRST, "Normal").setCheckable(false);
    mapSubMenu.add(1, Menu.FIRST + 2, Menu.FIRST + 2, "Satellite").setCheckable(false);
    mapSubMenu.add(1, Menu.FIRST + 3, Menu.FIRST + 3, "Terrain").setCheckable(false);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

/** Called whe the menu is created. */
@Override//from w w  w.  ja  va  2s . c o  m
public boolean onCreateOptionsMenu(Menu menu) {
    // zoom (invisible)
    menu.add(Menu.NONE, ID_ZOOM, Menu.NONE, Messages.getString("W_ZOOM"))
            .setIcon(android.R.drawable.ic_menu_zoom).setVisible(false);
    // mylocation (invisible)
    menu.add(Menu.NONE, ID_MYLOCATION, Menu.NONE, Messages.getString("W_MYLOCATION"))
            .setIcon(android.R.drawable.ic_menu_mylocation).setVisible(false);
    // maptypes (invisible)
    menu.add(Menu.NONE, ID_MAPTYPE, Menu.NONE, Messages.getString("W_CHANGE_MAP"))
            .setIcon(android.R.drawable.ic_menu_mapmode).setVisible(false);
    // geocoder (invisible)
    if (this.getGeocoderActivityClass() != null) {
        menu.add(Menu.NONE, ID_GEOCODER, Menu.NONE, Messages.getString("W_GEOCODER"))
                .setIcon(android.R.drawable.ic_menu_search).setVisible(false);
    }
    // more
    SubMenu smMore = menu.addSubMenu(Messages.getString("W_MORE")).setIcon(android.R.drawable.ic_menu_more);
    if (this.getPreferenceActivityClass() != null) {
        smMore.add(Menu.NONE, ID_MORE_PREFERENCES, Menu.NONE, Messages.getString("W_PREFERENCES"));
    }
    // more/externalmap (invisible)
    smMore.add(Menu.NONE, ID_MORE_EXTERNALMAP, Menu.NONE, Messages.getString("W_EXTERNALMAP"))
            .setVisible(false);
    // more/removedownloadedfiles (shown if needed)
    if (this.hasDownloadedFiles()) {
        smMore.add(Menu.NONE, ID_MORE_REMOVEDOWNLOADEDFILES, Menu.NONE,
                Messages.getString("W_REMOVEDOWNLOADEDFILES")).setIcon(android.R.drawable.ic_menu_delete);
    }
    // more/clearcache (2013/08/07)
    smMore.add(Menu.NONE, ID_MORE_CLEARCACHE, Menu.NONE, Messages.getString("W_CLEARCACHE"));

    // more/about
    smMore.add(Menu.NONE, ID_MORE_ABOUT, Menu.NONE, Messages.getString("W_ABOUT"));
    // more/exit
    smMore.add(Menu.NONE, ID_MORE_EXIT, Menu.NONE, Messages.getString("W_EXIT"));
    return super.onCreateOptionsMenu(menu);
}