Example usage for android.view MenuItem setAlphabeticShortcut

List of usage examples for android.view MenuItem setAlphabeticShortcut

Introduction

In this page you can find the example usage for android.view MenuItem setAlphabeticShortcut.

Prototype

public MenuItem setAlphabeticShortcut(char alphaChar);

Source Link

Document

Change the alphabetic shortcut associated with this item.

Usage

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

private void handleMoreMenu(Menu menu, boolean forceFromToolbar, int max) {
    if (forceFromToolbar || (menu.size() > max && Build.VERSION.SDK_INT > 13 && getWindowWidth() < 700)) {
        MenuItem more = menu.findItem(R.id.menu_more);
        if (more != null) {
            SubMenu moreSub = more.getSubMenu();
            if (moreSub != null) {
                for (int i = Math.max(0, max - 1); i < menu.size(); i++) {
                    MenuItem item = menu.getItem(i);
                    if (item.getItemId() == R.id.menu_more)
                        continue;
                    MenuItem ni = MenuUtils.transferMenu(item, moreSub);
                    if (ni == null)
                        continue;
                    ni.setAlphabeticShortcut((char) ('a' + i));
                    item.setVisible(false);
                }//  w w  w. j ava 2 s . co  m
                MenuUtils.scanMenuShortcuts(moreSub);
            }
        }

    } else
        MenuUtils.setMenuVisible(menu, false, R.id.menu_more);
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    MenuItem item;

    // If the trackball is held down, then the context menu pops up and
    // we never get onKeyUp() for the long-press. So check for it here
    // and change the selection to the long-press state.
    /*if (mSelectionMode != SELECTION_LONGPRESS) {
    mSelectionMode = SELECTION_LONGPRESS;
    invalidate();//from w  w w  .j  a  v  a  2s . c  o m
    }*/

    final long startMillis = getSelectedTimeInMillis();
    int flags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_CAP_NOON_MIDNIGHT | DateUtils.FORMAT_SHOW_WEEKDAY;
    final String title = DayUtils.formatDateRange(mContext, startMillis, startMillis, flags);
    menu.setHeaderTitle(title);

    int numSelectedEvents = mSelectedEvents.size();
    if (mNumDays == 1) {
        // Day view.

        // If there is a selected event, then allow it to be viewed and
        // edited.
        if (numSelectedEvents >= 1) {
            item = menu.add(0, MENU_EVENT_VIEW, 0, "View event");
            item.setOnMenuItemClickListener(mContextMenuHandler);
            item.setIcon(android.R.drawable.ic_menu_info_details);
        }
    } else {
        // Week view.

        // If there is a selected event, then allow it to be viewed and
        // edited.
        if (numSelectedEvents >= 1) {
            item = menu.add(0, MENU_EVENT_VIEW, 0, "View event");
            item.setOnMenuItemClickListener(mContextMenuHandler);
            item.setIcon(android.R.drawable.ic_menu_info_details);
        }

        item = menu.add(0, MENU_DAY, 0, "Show day");
        item.setOnMenuItemClickListener(mContextMenuHandler);
        item.setIcon(android.R.drawable.ic_menu_day);
        item.setAlphabeticShortcut('d');
    }
}