Example usage for android.view SubMenu getItem

List of usage examples for android.view SubMenu getItem

Introduction

In this page you can find the example usage for android.view SubMenu getItem.

Prototype

public MenuItem getItem();

Source Link

Document

Gets the MenuItem that represents this submenu in the parent menu.

Usage

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

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;

    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_historysearch_delete, Menu.FIRST, R.string.delete);
    createMenu.setIcon(R.drawable.ic_delete);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

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

public static void getMenu(AlfrescoSession session, Menu menu, Folder parentFolder, boolean actionMode) {
    MenuItem mi;//from   www . j a  v  a  2  s  . c o  m

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

    if (!actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_SEARCH_FOLDER,
                Menu.FIRST + MenuActionItem.MENU_SEARCH_FOLDER, R.string.search);
        mi.setIcon(R.drawable.ic_search);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode && permission.canAddChildren()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER,
                Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create);
        mi.setIcon(R.drawable.ic_add_folder);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        SubMenu createMenu = menu.addSubMenu(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE, R.string.add_menu);
        createMenu.setIcon(android.R.drawable.ic_menu_add);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_UPLOAD, Menu.FIRST + MenuActionItem.MENU_UPLOAD,
                R.string.upload_title);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_CREATE_DOCUMENT,
                Menu.FIRST + MenuActionItem.MENU_CREATE_DOCUMENT, R.string.create_document);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO, R.string.take_photo);

        if (AndroidVersion.isICSOrAbove()) {
            createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
                    Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO, R.string.make_video);
        }

        createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO, R.string.record_audio);

    }

    if (actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_DETAILS, Menu.FIRST + MenuActionItem.MENU_DETAILS,
                R.string.action_view_properties);
        mi.setIcon(R.drawable.ic_details);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canEdit()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_EDIT, Menu.FIRST + MenuActionItem.MENU_EDIT,
                R.string.edit);
        mi.setIcon(R.drawable.ic_edit);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canDelete()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_DELETE, Menu.FIRST + MenuActionItem.MENU_DELETE,
                R.string.delete);
        mi.setIcon(R.drawable.ic_delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_REFRESH, Menu.FIRST + MenuActionItem.MENU_REFRESH,
                R.string.refresh);
        mi.setIcon(R.drawable.ic_refresh);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem searchBtn = menu.findItem(R.id.action_search);
    searchBtn.setVisible(true);//from   ww w.jav  a2  s.co m

    SubMenu selectionMenu = menu.addSubMenu(getResources().getString(R.string.selection_options_btn));
    selectionMenu.getItem().setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_edit)
            .colorRes(R.color.accentNoTransparency).actionBarSize());
    selectionMenu.getItem().setTitle(getResources().getString(R.string.selection_options_btn));
    selectionMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuItem selectAllItem = selectionMenu.add(getResources().getString(R.string.btn_select_all));
    selectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_check_square_o)
            .colorRes(R.color.accentNoTransparency).actionBarSize());
    selectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    selectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getActivity(), "Selected all items", Toast.LENGTH_SHORT).show();

            try {
                DBManager.setFilteredCompaniesSelected(true);
            } catch (SQLException e) {
                e.printStackTrace();
            }

            ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData();

            synchronized (RHCareerFairLayout.refreshMapNotifier) {
                RHCareerFairLayout.refreshMapNotifier.notifyChanged();
            }

            return true;
        }
    });

    MenuItem deselectAllItem = selectionMenu.add(getResources().getString(R.string.btn_deselect_all));
    deselectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_square_o)
            .colorRes(R.color.accentNoTransparency).actionBarSize());
    deselectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    deselectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getActivity(), "Deselected all items", Toast.LENGTH_SHORT).show();

            try {
                DBManager.setFilteredCompaniesSelected(false);
            } catch (SQLException e) {
                e.printStackTrace();
            }

            ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData();

            synchronized (RHCareerFairLayout.refreshMapNotifier) {
                RHCareerFairLayout.refreshMapNotifier.notifyChanged();
            }

            return true;
        }
    });
}

From source file:com.evvsoft.treeview.demo.DemoActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu sub = menu.addSubMenu("Theme");
    sub.add(0, R.style.Theme_TreeView_Light, 0, "Light");
    sub.add(0, R.style.Theme_TreeView_Dark, 0, "Dark");
    sub.add(0, R.drawable.expander_custom_group_holo_light, 0, "Custom group indicator");
    sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*  w w  w. ja  v  a2s  . com*/
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActionMode.java

private void getMenu(Menu menu) {
    MenuItem mi;/*w ww  .  ja  va 2  s  .  co m*/
    menu.clear();

    mi = menu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_DELETE_ID,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings);
    mi.setIcon(R.drawable.ic_delete);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // GROUP MENU
    if (selectedSpenObjects.size() > 1) {
        SubMenu groupSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
                R.string.editor_group_menu);
        groupSubMenu.setIcon(R.drawable.ic_group);
        groupSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID, R.string.editor_group);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID, R.string.editor_ungroup);

        mi.setEnabled(false);
        for (SpenObjectBase obj : selectedSpenObjects) {
            if (obj.getType() == SpenObjectBase.TYPE_CONTAINER) {
                mi.setEnabled(true);
                break;
            }
        }
    }

    // UP MENU
    SubMenu upMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_front_menu);
    upMenu.setIcon(R.drawable.ic_move_up);
    upMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID, R.string.editor_forward);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID, R.string.editor_front);

    // DOWN MENU
    SubMenu downMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_back_menu);
    downMenu.setIcon(R.drawable.ic_move_down);
    downMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID, R.string.editor_backward);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID, R.string.editor_back);
}

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

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;

    // SYNC/*from  w  w w  .j ava  2s.co m*/
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 2, R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 3, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }
}

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]);/*from   w  w  w. j  a va 2s.co  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: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));
    /**//from  w  w w  .  j a  v a  2  s. c  o  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:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    toolsSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_tools);/*from ww w . java2  s  . c  o  m*/
    toolsSubMenu.setIcon(R.drawable.ic_edit);
    toolsSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    // TOOLS MENU
    MenuItem mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PEN,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PEN, R.string.editor_pen);
    mi.setIcon(R.drawable.ic_edit);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TEXT,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_TEXT, R.string.editor_text);
    mi.setIcon(R.drawable.ic_text);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SELECTION,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SELECTION, R.string.editor_selection);
    mi.setIcon(R.drawable.ic_selection);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ERASER,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ERASER, R.string.editor_eraser);
    mi.setIcon(R.drawable.ic_eraser);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // TOOL SETTINGS MENU
    SubMenu toolsSettingSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings);
    toolsSettingSubMenu.setIcon(R.drawable.ic_action_settings);
    toolsSettingSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN, R.string.editor_pen);
    mi.setIcon(R.drawable.ic_edit);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT, R.string.editor_text);
    mi.setIcon(R.drawable.ic_text);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION, R.string.editor_selection);
    mi.setIcon(R.drawable.ic_selection);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER, R.string.editor_eraser);
    mi.setIcon(R.drawable.ic_eraser);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // ADD MENU
    SubMenu addSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD, R.string.editor_add_menu);
    addSubMenu.setIcon(R.drawable.ic_add);
    addSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    // IMAGE
    mi = addSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE, R.string.editor_add_image);
    mi.setIcon(R.drawable.ic_add_image);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // PAGES
    SubMenu pagesMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE, R.string.editor_pages);
    pagesMenu.setIcon(R.drawable.ic_pages);
    pagesMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE, R.string.editor_pages_move);
    mi.setIcon(R.drawable.ic_pages);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD, R.string.editor_pages_add);
    mi.setIcon(R.drawable.ic_add_page);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE, R.string.editor_pages_remove);
    mi.setIcon(R.drawable.ic_delete);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // EXTRA SETTINGS
    // SAVE
    mi = menu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SAVE,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SAVE, R.string.editor_save);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    super.onCreateOptionsMenu(menu);

    return true;
}

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

protected void getMenu(FragmentActivity activity, Menu menu) {
    MenuItem mi;//  w w  w .  j  av a 2s  .c o  m
    SubMenu createMenu;

    if (selectedFolder.isEmpty()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_download_all, Menu.FIRST, R.string.download);
        mi.setIcon(R.drawable.ic_download_light);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD);

        if (!(SessionUtils.getSession(activity) instanceof CloudSession)) {
            mi = menu.add(Menu.NONE, R.id.menu_workflow_review_attachments, Menu.FIRST + 500,
                    R.string.process_start_review);
            mi.setIcon(R.drawable.ic_start_review);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_REVIEW);
        }
    }

    // SYNC
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())
            && !SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), parentFolder)) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 135,
            R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 150, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }

    if (parentFolder != null && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(),
            parentFolder, ConfigurableActionHelper.ACTION_NODE_DELETE)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
        mi.setIcon(R.drawable.ic_delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DELETE);
    }
}