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:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (searchMode) {
        currentMenu = null;// w  w  w .j av  a  2 s .  com
        menu.add(0, ListPage.OPTIONS_MENU_SEARCH_VIEW, 0, "").setActionView(getSearchView(true))
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    } else {
        currentMenu = menu;
        if (page != null) {
            page.onCreateOptionsMenu(menu);
            sendPrepareMenuToPage = true;
        }
        MenuItem appearanceOptionsItem = menu.findItem(ListPage.OPTIONS_MENU_APPEARANCE);
        if (appearanceOptionsItem != null) {
            Menu appearanceOptionsMenu = appearanceOptionsItem.getSubMenu();
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_CHANGE_THEME, 0,
                    R.string.action_change_theme);
            appearanceOptionsMenu
                    .add(0, ListPage.APPEARANCE_MENU_EXPANDED_SCREEN, 0, R.string.action_expanded_screen)
                    .setCheckable(true);
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_SPOILERS, 0, R.string.action_spoilers)
                    .setCheckable(true);
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_MY_POSTS, 0, R.string.action_my_posts)
                    .setCheckable(true);
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_DRAWER, 0, R.string.action_lock_drawer)
                    .setCheckable(true);
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_THREADS_GRID, 0, R.string.action_threads_grid)
                    .setCheckable(true);
            appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_SFW_MODE, 0, R.string.action_sfw_mode)
                    .setCheckable(true);
        }
        actionMenuConfigurator.onAfterCreateOptionsMenu(menu);
    }
    return true;
}

From source file:com.hichinaschool.flashcards.anki.CardBrowser.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item;// w w  w.j  a  va2 s .c o m
    // TODO(flerda@gmail.com): Fix card browser's undo.
    // https://code.google.com/p/ankidroid/issues/detail?id=1561
    /*
    item = menu.add(Menu.NONE, MENU_UNDO, Menu.NONE, R.string.undo);
    item.setIcon(R.drawable.ic_menu_revert);
    */
    item = menu.add(Menu.NONE, MENU_ADD_NOTE, Menu.NONE, R.string.card_editor_add_card);
    item.setIcon(R.drawable.ic_menu_add);
    // TODO(flerda@gmail.com): Fix card browser fields.
    // https://code.google.com/p/ankidroid/issues/detail?id=1310
    // Currently this is disabled because it is obvious what to do when cards with different models are present in
    // the deck.
    /*
    if (mWholeCollection == false) {
    item = menu.add(Menu.NONE, MENU_FIELD, Menu.NONE, R.string.card_browser_field);
    item.setIcon(R.drawable.ic_menu_add);
    }
    */
    item = menu.add(Menu.NONE, MENU_CHANGE_ORDER, Menu.NONE, R.string.card_browser_change_display_order);
    item.setIcon(R.drawable.ic_menu_sort_by_size);
    item = menu.add(Menu.NONE, MENU_SHOW_MARKED, Menu.NONE, R.string.card_browser_show_marked);
    item.setIcon(R.drawable.ic_menu_star_on);
    item = menu.add(Menu.NONE, MENU_SELECT_SUSPENDED, Menu.NONE, R.string.card_browser_show_suspended);
    item.setIcon(R.drawable.ic_menu_close_clear_cancel);
    item = menu.add(Menu.NONE, MENU_SELECT_TAG, Menu.NONE, R.string.card_browser_search_by_tag);
    item.setIcon(R.drawable.ic_menu_search);
    return true;
}

From source file:mp.teardrop.LibraryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, MENU_UNLINK_WITH_DROPBOX, 91, R.string.unlink_with_dropbox);
    return true;//from   w  w w . j av  a2 s .  c o m
}

From source file:com.jins_meme.bridge.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int index = 0;

    menu.add(0, index++, 0, R.string.basic_conf);

    /*/*  w w w  . j a  va  2s  .c  o  m*/
     * MODIFY YOURSELF
     * Add your implemented function's configuration
     *
     */
    menu.add(0, index++, 0, R.string.spotify_conf);
    menu.add(0, index++, 0, R.string.remo_conf);
    menu.add(0, index++, 0, R.string.hue_conf);
    menu.add(0, index++, 0, getString(R.string.osc_conf) + " (for Eye VDJ)");
    menu.add(0, index++, 0, getString(R.string.midi_conf) + " (for Eye VDJ)");

    menu.add(0, index++, 0, R.string.about);
    menu.add(0, index, 0, R.string.exit_app);

    return true;
}

From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java

public void getMenu(Menu menu) {
    if (parentFolder == null) {
        return;//from  w w  w.  jav a2 s. com
    }

    if (getActivity() instanceof MainActivity) {
        getMenu(getSession(), menu, parentFolder);

        if (hasDocument()) {
            displayMenuItem = menu.add(Menu.NONE, R.id.menu_gallery, Menu.FIRST, R.string.display_gallery);
            displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    } else if (getActivity() instanceof PublicDispatcherActivity
            || getActivity() instanceof BaseShortcutActivity) {
        // permission =
        // getSession().getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);
        if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder,
                ConfigurableActionHelper.ACTION_CREATE_FOLDER)) {
            MenuItem mi = menu.add(Menu.NONE, R.id.menu_create_folder, Menu.FIRST, R.string.folder_create);
            mi.setIcon(R.drawable.ic_repository_light);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
    }

    MenuFragmentHelper.getMenu(getActivity(), menu);
}

From source file:com.google.appinventor.components.runtime.Form.java

public void addAboutInfoToMenu(Menu menu) {
    MenuItem aboutAppItem = menu.add(Menu.NONE, Menu.NONE, 2, "About this application")
            .setOnMenuItemClickListener(new OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {
                    showAboutApplicationNotification();
                    return true;
                }/*w w w . j a  v  a 2 s.  c o m*/
            });
    aboutAppItem.setIcon(android.R.drawable.sym_def_app_icon);
}

From source file:id.ridon.keude.AppDetailsData.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    super.onPrepareOptionsMenu(menu);
    menu.clear();//from   w w  w  .jav a  2s  .  c  o  m
    if (app == null)
        return true;
    if (app.canAndWantToUpdate()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, INSTALL, 0, R.string.menu_upgrade).setIcon(R.drawable.ic_menu_refresh),
                MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    }

    // Check count > 0 due to incompatible apps resulting in an empty list.
    if (!app.isInstalled() && app.suggestedVercode > 0 && adapter.getCount() > 0) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, INSTALL, 1, R.string.menu_install).setIcon(android.R.drawable.ic_menu_add),
                MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    } else if (app.isInstalled()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall)
                        .setIcon(android.R.drawable.ic_menu_delete),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);

        if (mPm.getLaunchIntentForPackage(app.id) != null) {
            MenuItemCompat.setShowAsAction(
                    menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch)
                            .setIcon(android.R.drawable.ic_media_play),
                    MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
        }
    }

    MenuItemCompat.setShowAsAction(
            menu.add(Menu.NONE, SHARE, 1, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share),
            MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(Menu.NONE, IGNOREALL, 2, R.string.menu_ignore_all)
            .setIcon(android.R.drawable.ic_menu_close_clear_cancel).setCheckable(true)
            .setChecked(app.ignoreAllUpdates);

    if (app.hasUpdates()) {
        menu.add(Menu.NONE, IGNORETHIS, 2, R.string.menu_ignore_this)
                .setIcon(android.R.drawable.ic_menu_close_clear_cancel).setCheckable(true)
                .setChecked(app.ignoreThisUpdate >= app.suggestedVercode);
    }
    if (app.webURL.length() > 0) {
        menu.add(Menu.NONE, WEBSITE, 3, R.string.menu_website).setIcon(android.R.drawable.ic_menu_view);
    }
    if (app.trackerURL.length() > 0) {
        menu.add(Menu.NONE, ISSUES, 4, R.string.menu_issues).setIcon(android.R.drawable.ic_menu_view);
    }
    if (app.sourceURL.length() > 0) {
        menu.add(Menu.NONE, SOURCE, 5, R.string.menu_source).setIcon(android.R.drawable.ic_menu_view);
    }

    if (app.bitcoinAddr != null || app.litecoinAddr != null || app.dogecoinAddr != null || app.flattrID != null
            || app.donateURL != null) {
        SubMenu donate = menu.addSubMenu(Menu.NONE, DONATE, 7, R.string.menu_donate)
                .setIcon(android.R.drawable.ic_menu_send);
        if (app.bitcoinAddr != null)
            donate.add(Menu.NONE, BITCOIN, 8, R.string.menu_bitcoin);
        if (app.litecoinAddr != null)
            donate.add(Menu.NONE, LITECOIN, 8, R.string.menu_litecoin);
        if (app.dogecoinAddr != null)
            donate.add(Menu.NONE, DOGECOIN, 8, R.string.menu_dogecoin);
        if (app.flattrID != null)
            donate.add(Menu.NONE, FLATTR, 9, R.string.menu_flattr);
        if (app.donateURL != null)
            donate.add(Menu.NONE, DONATE_URL, 10, R.string.menu_website);
    }
    if (app.isInstalled() && fdroidApp.bluetoothAdapter != null) { // ignore on devices without Bluetooth
        menu.add(Menu.NONE, SEND_VIA_BLUETOOTH, 6, R.string.send_via_bluetooth);
    }

    return true;
}

From source file:com.google.appinventor.components.runtime.Form.java

public void addExitButtonToMenu(Menu menu) {
    MenuItem stopApplicationItem = menu.add(Menu.NONE, Menu.NONE, Menu.FIRST, "Stop this application")
            .setOnMenuItemClickListener(new OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {
                    showExitApplicationNotification();
                    return true;
                }//www .jav  a  2s  .co  m
            });
    stopApplicationItem.setIcon(android.R.drawable.ic_notification_clear_all);
}

From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java

public void getMenu(AlfrescoSession session, Menu menu, Folder parentFolder) {
    MenuItem mi;//from  www.  j  a  va2s .c  o m

    if (parentFolder == null) {
        return;
    }
    try {
        permission = session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);
    } catch (Exception e) {
        return;
    }

    mi = menu.add(Menu.NONE, R.id.menu_search_from_folder, Menu.FIRST + 10, R.string.search);
    mi.setIcon(R.drawable.ic_search_light);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder,
            ConfigurableActionHelper.ACTION_CREATE_DOC)
            || ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder,
                    ConfigurableActionHelper.ACTION_CREATE_FOLDER)
            || ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder,
                    ConfigurableActionHelper.ACTION_NODE_UPLOAD)) {
        displayFab();
    }
}