Example usage for android.view Menu add

List of usage examples for android.view Menu add

Introduction

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

Prototype

public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);

Source Link

Document

Variation on #add(int,int,int,CharSequence) that takes a string resource identifier instead of the string itself.

Usage

From source file:Main.java

static public boolean doCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_KEYBOARD_SPECIAL, 0, "Special Keys");

    menu.add(0, MENU_FIT, 0, "Resize");
    SubMenu inputModeMenu = menu.addSubMenu("Input Mode");
    inputModeMenu.add(1, MENU_INPUT_MOUSE, 0, "Trackpad").setChecked(true);
    inputModeMenu.add(1, MENU_INPUT_JOYSTICK, 0, "Joystick");
    inputModeMenu.add(1, MENU_INPUT_SCROLL, 0, "Scroll Screen");
    inputModeMenu.setGroupCheckable(1, true, true);

    inputModeMenu.add(0, MENU_INPUT_SWAP_JOYPORT, 0, "Swap Joystick Ports");

    inputModeMenu.add(0, MENU_INPUT_HARDKEY, 0, "Vol. Up/Down as button").setCheckable(true);
    inputModeMenu.add(0, MENU_INPUT_USE_LEFT_ALT, 0, "Map Left-Alt Key").setCheckable(true);
    inputModeMenu.add(0, MENU_INPUT_TAP_CLICK, 0, "Tap Screen as click").setCheckable(true);
    inputModeMenu.add(0, MENU_INPUT_INPUT_METHOD, 0, "Input Method");
    inputModeMenu.add(0, MENU_INPUT_FORCE_KEYBOARD, 0, "Show Keyboard Fix").setCheckable(true);
    inputModeMenu.add(0, MENU_INPUT_KEYUP_DELAY, 0, "Keypress Fix").setCheckable(true);

    SubMenu buttonMenu = menu.addSubMenu("Buttons");
    buttonMenu.add(1, MENU_BUTTON_HIDE, 0, "Hide Buttons");
    buttonMenu.add(1, MENU_BUTTON_SHOW, 0, "Show Buttons (Slower)").setChecked(true);
    buttonMenu.add(1, MENU_BUTTON_OFF, 0, "Disable Buttons");
    buttonMenu.setGroupCheckable(1, true, true);
    buttonMenu.add(0, MENU_BUTTON_ALWAYS_SHOW_JOYSTICK, 0, "Always Show Joystick").setCheckable(true);
    buttonMenu.add(0, MENU_BUTTON_LARGE_JOYSTICK, 0, "Large Joystick").setCheckable(true);

    SubMenu settingMenu = menu.addSubMenu("Settings");
    settingMenu.add(0, MENU_SETTINGS_FRAMESKIP, 0, "Frameskip");
    settingMenu.add(0, MENU_SETTINGS_BETTER_VIDEO, 0, "Better Video").setCheckable(true);
    settingMenu.add(0, MENU_SETTINGS_SHOW_INFO, 0, "Show Info").setCheckable(true);
    settingMenu.add(0, MENU_SETTINGS_TRUE_DRIVE, 0, "True Drive Emulation").setCheckable(true);
    settingMenu.add(0, MENU_SETTINGS_SCALE_FILTER, 0, "Smooth Resize (Slower)").setCheckable(true);
    settingMenu.add(0, MENU_SETTINGS_SCALE_FACTOR, 0, "Resize Mode");
    settingMenu.add(0, MENU_SETTINGS_FAST_MOUSE, 0, "Better Mouse (Slower)").setCheckable(true);
    settingMenu.add(0, MENU_SETTINGS_MOUSE_SENSITIVITY, 0, "Mouse Sensitivity");
    settingMenu.add(0, MENU_SETTINGS_JOYKEY_SET, 0, "Joystick Keys");
    settingMenu.add(0, MENU_SETTINGS_KEY_MAPPER, 0, "Button Mapper");
    settingMenu.add(0, MENU_SETTINGS_HELP, 0, "Help");
    settingMenu.add(0, MENU_SETTINGS_LICENSE, 0, "Save license to /sdcard/gpl.txt");

    menu.add(0, MENU_KEYBOARD, 0, "Keyboard");
    return true;/* w w w.j av a2 s . com*/
}

From source file:org.alfresco.mobile.android.application.fragments.MenuFragmentHelper.java

public static MenuItem getMenu(Context context, Menu menu) {
    if (menu == null || context == null) {
        return null;
    }/* w  w  w. j av a2  s . c  o m*/
    if (AccessibilityUtils.isEnabled(context)) {
        MenuItem mi = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST + 40, R.string.refresh);
        mi.setIcon(R.drawable.ic_refresh);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        return mi;
    } else {
        return null;
    }
}

From source file:org.openremote.android.console.Main.java

public static void populateMenu(Menu menu) {
    menu.setQwertyMode(true);/*www. j  ava 2s  .com*/
    MenuItem configItem = menu.add(0, Constants.MENU_ITEM_SETTING, 0, R.string.configure);
    configItem.setIcon(R.drawable.ic_menu_manage);
    MenuItem quit = menu.add(0, Constants.MENU_ITEM_QUIT, 0, R.string.quit);
    quit.setIcon(R.drawable.ic_menu_close_clear_cancel);
}

From source file:com.arantius.tivocommander.Utils.java

@SuppressLint("NewApi")
final static void addToMenu(Menu menu, Activity activity, int itemId, int iconId, String title,
        int showAsAction) {
    if (Utils.activityForMenuId(itemId) == activity.getClass()) {
        return;// w ww  . ja  v  a2  s. co m
    }
    MenuItem menuitem = menu.add(Menu.NONE, itemId, Menu.NONE, title);
    menuitem.setIcon(iconId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuitem.setShowAsAction(showAsAction);
    }
}

From source file:org.alfresco.mobile.android.application.fragments.search.SearchFragment.java

public static void getMenu(Menu menu) {
    MenuItem mi = menu.add(Menu.NONE, R.id.menu_search_option, Menu.FIRST, R.string.search_advanced);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

public static void getMenu(Menu menu) {
    MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_PROFILE, Menu.FIRST + MenuActionItem.MENU_PROFILE,
            R.string.my_profile);/*  ww  w .  java 2 s  .co  m*/
    mi.setIcon(R.drawable.ic_avatar);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_DOWNLOAD, 0, R.string.menu_download);
    menu.add(0, MENU_SETTINGS, 0, R.string.menu_settings);
    return true;/*  w ww  . j av  a 2  s. c  o  m*/
}

From source file:com.thinkthinkdo.pff_appsettings.PermissionListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, ABOUT, 0, "About");
    return true;
}

From source file:com.loopj.android.http.sample.Redirect302Sample.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(Menu.NONE, 0, Menu.NONE, "Enable redirects").setCheckable(true);
    menu.add(Menu.NONE, 1, Menu.NONE, "Enable relative redirects").setCheckable(true);
    menu.add(Menu.NONE, 2, Menu.NONE, "Enable circular redirects").setCheckable(true);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.commonsware.android.arXiv.DownloadsActivity.java

private void populateMenu(Menu menu) {
    menu.add(Menu.NONE, CLEAR_ID, Menu.NONE, R.string.clear_history);
}