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(int groupId, int itemId, int order, @StringRes int titleRes);

Source Link

Document

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

Usage

From source file:Main.java

public static void addItems2Menu(Menu menu, int idx, String nume, ViewPager vp) {
    final SubMenu smenu = menu.addSubMenu(0, idx, 0, nume);
    for (int i = 0; i < vp.getAdapter().getCount(); i++) {
        if (i != vp.getCurrentItem())
            smenu.add(0, idx + i + 1, 0, vp.getAdapter().getPageTitle(i));
    }/*  w w w.j ava  2s . co  m*/
}

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

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;//from w  w  w .j a v  a 2  s . com

    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.actions.NodeIdActions.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;/*from  ww  w .j a v  a2 s  .  co m*/

    // SYNC
    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:com.mifos.mifosxdroid.online.LoanAccountSummaryFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();//www .  j  a  v a 2 s  .c  o m
    menu.addSubMenu(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_LOAN_NAME);
    menu.add(Menu.NONE, MENU_ITEM_LOAN_TRANSACTIONS, Menu.NONE,
            getResources().getString(R.string.transactions));
    menu.add(Menu.NONE, MENU_ITEM_REPAYMENT_SCHEDULE, Menu.NONE,
            getResources().getString(R.string.loan_repayment_schedule));
    menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents));
    menu.add(Menu.NONE, MENU_ITEM_CHARGES, Menu.NONE, getResources().getString(R.string.charges));

    int SUBMENU_ITEM_ID = 0;

    // Create a Sub Menu that holds a link to all data tables
    SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu();
    if (dataTableSubMenu != null && loanDataTables != null && loanDataTables.size() > 0) {
        Iterator<DataTable> dataTableIterator = loanDataTables.iterator();
        while (dataTableIterator.hasNext()) {
            dataTableSubMenu.add(Menu.NONE, SUBMENU_ITEM_ID, Menu.NONE,
                    dataTableIterator.next().getRegisteredTableName());
            SUBMENU_ITEM_ID++;
        }
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:com.mifos.mifosxdroid.online.SavingsAccountSummaryFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*from   ww  w . j  a  va2 s. c o m*/
    menu.addSubMenu(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME);
    menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents));

    // This is the ID of Each data table which will be used in onOptionsItemSelected Method
    int SUBMENU_ITEM_ID = 0;
    // Create a Sub Menu that holds a link to all data tables
    SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu();
    if (dataTableSubMenu != null && savingsAccountDataTables != null && savingsAccountDataTables.size() > 0) {
        Iterator<DataTable> dataTableIterator = savingsAccountDataTables.iterator();
        while (dataTableIterator.hasNext()) {
            dataTableSubMenu.add(Menu.NONE, SUBMENU_ITEM_ID, Menu.NONE,
                    dataTableIterator.next().getRegisteredTableName());
            SUBMENU_ITEM_ID++;
        }
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:me.fattycat.kun.teamwork.ui.activity.MainActivity.java

private void initTeamProjectMenu(boolean isClear) {
    LogUtils.i(TAG, "initTeamProjectMenu");

    Menu menu = mNavView.getMenu();
    menu.removeGroup(233);//from  w  ww.jav  a  2 s  .com
    SubMenu projectMenu = menu.addSubMenu(233, Menu.NONE, Menu.NONE,
            String.format("%s %s", getString(R.string.text_menu_project),
                    TWSettings.sTeamList.get(TWSettings.sSelectedTeamPos).getName()));

    if (isClear) {
        projectMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, " ...").setCheckable(true)
                .setIcon(android.R.color.transparent);
        return;
    }

    int index = 0;
    for (TeamProjectModel model : mTeamProjectList) {
        projectMenu.add(Menu.NONE, index++, Menu.NONE, model.getName()).setCheckable(true)
                .setIcon(android.R.color.transparent);
    }

    if (index == 0) {
        projectMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, "").setCheckable(true)
                .setIcon(android.R.color.transparent);
    }

}

From source file:com.actionbarsherlock.internal.view.MenuItemImpl.java

public void addTo(android.view.Menu menu) {
    if (this.mSubMenu != null) {
        android.view.SubMenu subMenu = menu.addSubMenu(this.mGroupId, this.mItemId, this.mOrder, this.mTitle);
        if (mIconRes != View.NO_ID) {
            subMenu.setIcon(mIconRes);/*  ww w .  j a va  2  s . c om*/
        } else {
            subMenu.setIcon(mIcon);
        }

        for (MenuItemImpl item : this.mSubMenu.getItems()) {
            item.addTo(subMenu);
        }
    } else {
        android.view.MenuItem item = menu.add(this.mGroupId, this.mItemId, this.mOrder, this.mTitle)
                .setAlphabeticShortcut(this.mAlphabeticalShortcut).setNumericShortcut(this.mNumericalShortcut)
                .setVisible(this.isVisible()).setIntent(this.mIntent)
                .setOnMenuItemClickListener(this.mClickListener);

        if (this.isExclusiveCheckable()) {
            menu.setGroupCheckable(this.mGroupId, true, true);
        }

        //Create and initialize a native itemview wrapper
        NativeMenuItemView nativeWrapper = new NativeMenuItemView(item);
        nativeWrapper.initialize(this, MenuBuilder.TYPE_NATIVE);

        //Associate the itemview to this so changes will be reflected
        setItemView(MenuBuilder.TYPE_NATIVE, nativeWrapper);
    }
}

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

private void getMenu(Menu menu) {
    MenuItem mi;//  w ww  . j  a  v a  2s.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.span.manager.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean supRetVal = super.onCreateOptionsMenu(menu);
    SubMenu setup = menu.addSubMenu(0, MENU_CHANGE_SETTINGS, 0, getString(R.string.main_activity_settings));
    setup.setIcon(drawable.ic_menu_preferences);
    SubMenu about = menu.addSubMenu(0, MENU_ABOUT, 0, getString(R.string.main_activity_about));
    about.setIcon(drawable.ic_menu_info_details);
    SubMenu send = menu.addSubMenu(0, MENU_SEND_MESSAGE, 0, getString(R.string.main_activity_send_message));
    SubMenu info = menu.addSubMenu(0, MENU_VIEW_ROUTING_INFO, 0,
            getString(R.string.main_activity_view_routing_info));
    // info.setIcon(drawable.ic_menu_agenda);
    // SubMenu log = menu.addSubMenu(0, MENU_VIEW_LOG, 0, getString(R.string.main_activity_show_log));
    SubMenu share = menu.addSubMenu(0, MENU_SHARE, 0, getString(R.string.main_activity_share));
    return supRetVal;
}

From source file:com.cyanogenmod.effem.FmRadio.java

/**
 * Sets up the options menu when the menu button is pushed, dynamic
 * population of the station select menu
 *//*  ww  w  .j ava 2s.  c o m*/
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    boolean result = super.onCreateOptionsMenu(menu);

    // Create and populate the band selection menu
    SubMenu subMenu = menu.addSubMenu(BASE_OPTION_MENU, FM_BAND, Menu.NONE, R.string.band_select);
    subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
    subMenu.add(BAND_SELECTION_MENU, BAND_US, Menu.NONE, R.string.band_us);
    subMenu.add(BAND_SELECTION_MENU, BAND_EU, Menu.NONE, R.string.band_eu);
    subMenu.add(BAND_SELECTION_MENU, BAND_JAPAN, Menu.NONE, R.string.band_ja);
    subMenu.add(BAND_SELECTION_MENU, BAND_CHINA, Menu.NONE, R.string.band_ch);
    subMenu.setGroupCheckable(BAND_SELECTION_MENU, true, true);
    subMenu.getItem(mSelectedBand).setChecked(true);

    // Create and populate the speaker/headset selection menu if speaker supported
    if (context.getResources().getBoolean(R.bool.speaker_supported)) {
        subMenu = menu.addSubMenu(BASE_OPTION_MENU, OUTPUT_SOUND, Menu.NONE, R.string.output_select);
        subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
        subMenu.add(LOUDSPEAKER_SELECTION_MENU, OUTPUT_HEADSET, Menu.NONE, R.string.output_select_default);
        subMenu.add(LOUDSPEAKER_SELECTION_MENU, OUTPUT_SPEAKER, Menu.NONE, R.string.output_select_loudspeaker);
        subMenu.setGroupCheckable(LOUDSPEAKER_SELECTION_MENU, true, true);
        subMenu.getItem(mSelectedOutput).setChecked(true);
    }

    // Create the station select menu
    subMenu = menu.addSubMenu(BASE_OPTION_MENU, STATION_SELECT, Menu.NONE, R.string.station_select);
    subMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    // Dynamically populate the station select menu
    if (mMenuAdapter.isEmpty()) {
        subMenu.setGroupEnabled(STATION_SELECTION_MENU, false);
    } else {
        subMenu.setGroupEnabled(STATION_SELECTION_MENU, true);
        for (int i = 0; i < mMenuAdapter.getCount(); i++) {
            subMenu.add(STATION_SELECTION_MENU, STATION_SELECT_MENU_ITEMS + i, Menu.NONE,
                    mMenuAdapter.getItem(i).toString());
        }
    }
    return result;
}