Example usage for android.view Menu NONE

List of usage examples for android.view Menu NONE

Introduction

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

Prototype

int NONE

To view the source code for android.view Menu NONE.

Click Source Link

Document

Value to use for group and item identifier integers when you don't care about them.

Usage

From source file:com.jtechme.apphub.AppDetailsData.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.clear();//from ww  w .  j a v a2  s  .co m
    if (app == null)
        return true;

    if (mPm.getLaunchIntentForPackage(app.packageName) != null && app.canAndWantToUpdate()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch).setIcon(R.drawable.ic_play_arrow_white),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    }

    if (app.isInstalled()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall).setIcon(R.drawable.ic_delete_white),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    }

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

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

    if (app.hasUpdates()) {
        menu.add(Menu.NONE, IGNORETHIS, 2, R.string.menu_ignore_this)
                .setIcon(R.drawable.ic_do_not_disturb_white).setCheckable(true)
                .setChecked(app.ignoreThisUpdate >= app.suggestedVercode);
    }

    // Ignore on devices without Bluetooth
    if (app.isInstalled() && fdroidApp.bluetoothAdapter != null) {
        menu.add(Menu.NONE, SEND_VIA_BLUETOOTH, 3, R.string.send_via_bluetooth)
                .setIcon(R.drawable.ic_bluetooth_white);
    }
    return true;
}

From source file:com.nttec.everychan.ui.NewTabFragment.java

private void openChansList() {
    final ArrayAdapter<ChanModule> chansAdapter = new ArrayAdapter<ChanModule>(activity, 0) {
        private LayoutInflater inflater = LayoutInflater.from(activity);
        private int drawablePadding = (int) (resources.getDisplayMetrics().density * 5 + 0.5f);

        {/* ww  w.  j ava2 s  .  c om*/
            for (ChanModule chan : MainApplication.getInstance().chanModulesList)
                add(chan);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ChanModule chan = getItem(position);
            TextView view = (TextView) (convertView == null
                    ? inflater.inflate(android.R.layout.simple_list_item_1, parent, false)
                    : convertView);
            view.setText(chan.getDisplayingName());
            view.setCompoundDrawablesWithIntrinsicBounds(chan.getChanFavicon(), null, null, null);
            view.setCompoundDrawablePadding(drawablePadding);
            return view;
        }
    };

    DialogInterface.OnClickListener onChanSelected = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ChanModule chan = chansAdapter.getItem(which);
            UrlPageModel model = new UrlPageModel();
            model.chanName = chan.getChanName();
            model.type = UrlPageModel.TYPE_INDEXPAGE;
            openNewTab(chan.buildUrl(model));
        }
    };

    final AlertDialog chansListDialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.newtab_quickaccess_all_boards).setAdapter(chansAdapter, onChanSelected)
            .setNegativeButton(android.R.string.cancel, null).create();

    chansListDialog.getListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            MenuItem.OnMenuItemClickListener contextMenuHandler = new MenuItem.OnMenuItemClickListener() {
                @SuppressLint("InlinedApi")
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    final ChanModule chan = chansAdapter
                            .getItem(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position);
                    switch (item.getItemId()) {
                    case R.id.context_menu_favorites_from_fragment:
                        if (MainApplication.getInstance().database.isFavorite(chan.getChanName(), null, null,
                                null)) {
                            MainApplication.getInstance().database.removeFavorite(chan.getChanName(), null,
                                    null, null);
                        } else {
                            try {
                                UrlPageModel indexPage = new UrlPageModel();
                                indexPage.chanName = chan.getChanName();
                                indexPage.type = UrlPageModel.TYPE_INDEXPAGE;
                                MainApplication.getInstance().database.addFavorite(chan.getChanName(), null,
                                        null, null, chan.getChanName(), chan.buildUrl(indexPage));
                            } catch (Exception e) {
                                Logger.e(TAG, e);
                            }
                        }
                        return true;
                    case R.id.context_menu_quickaccess_add:
                        QuickAccess.Entry newEntry = new QuickAccess.Entry();
                        newEntry.chan = chan;
                        list.add(0, newEntry);
                        adapter.notifyDataSetChanged();
                        saveQuickAccessToPreferences();
                        chansListDialog.dismiss();
                        return true;
                    case R.id.context_menu_quickaccess_custom_board:
                        LinearLayout dialogLayout = new LinearLayout(activity);
                        dialogLayout.setOrientation(LinearLayout.VERTICAL);
                        final EditText boardField = new EditText(activity);
                        final EditText descriptionField = new EditText(activity);
                        boardField.setHint(R.string.newtab_quickaccess_addcustom_boardcode);
                        descriptionField.setHint(R.string.newtab_quickaccess_addcustom_boarddesc);
                        LinearLayout.LayoutParams fieldsParams = new LinearLayout.LayoutParams(
                                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                        dialogLayout.addView(boardField, fieldsParams);
                        dialogLayout.addView(descriptionField, fieldsParams);
                        DialogInterface.OnClickListener onOkClicked = new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String boardName = boardField.getText().toString();
                                for (QuickAccess.Entry entry : list)
                                    if (entry.boardName != null && entry.chan != null)
                                        if (entry.chan.getChanName().equals(chan.getChanName())
                                                && entry.boardName.equals(boardName)) {
                                            Toast.makeText(activity,
                                                    R.string.newtab_quickaccess_addcustom_already_exists,
                                                    Toast.LENGTH_LONG).show();
                                            return;
                                        }

                                try {
                                    if (boardName.trim().length() == 0)
                                        throw new Exception();
                                    UrlPageModel boardPageModel = new UrlPageModel();
                                    boardPageModel.type = UrlPageModel.TYPE_BOARDPAGE;
                                    boardPageModel.chanName = chan.getChanName();
                                    boardPageModel.boardName = boardName;
                                    boardPageModel.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
                                    chan.buildUrl(boardPageModel); //,  ??  ?    
                                } catch (Exception e) {
                                    Toast.makeText(activity,
                                            R.string.newtab_quickaccess_addcustom_incorrect_code,
                                            Toast.LENGTH_LONG).show();
                                    return;
                                }

                                QuickAccess.Entry newEntry = new QuickAccess.Entry();
                                newEntry.chan = chan;
                                newEntry.boardName = boardName;
                                newEntry.boardDescription = descriptionField.getText().toString();
                                list.add(0, newEntry);
                                adapter.notifyDataSetChanged();
                                saveQuickAccessToPreferences();
                                chansListDialog.dismiss();
                            }
                        };
                        new AlertDialog.Builder(activity)
                                .setTitle(resources.getString(R.string.newtab_quickaccess_addcustom_title,
                                        chan.getChanName()))
                                .setView(dialogLayout).setPositiveButton(android.R.string.ok, onOkClicked)
                                .setNegativeButton(android.R.string.cancel, null).show();
                        return true;
                    }
                    return false;
                }
            };
            String thisChanName = chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)
                    .getChanName();
            boolean canAddToQuickAccess = true;
            for (QuickAccess.Entry entry : list)
                if (entry.boardName == null && entry.chan != null
                        && entry.chan.getChanName().equals(thisChanName)) {
                    canAddToQuickAccess = false;
                    break;
                }
            menu.add(Menu.NONE, R.id.context_menu_favorites_from_fragment, 1,
                    MainApplication.getInstance().database.isFavorite(thisChanName, null, null, null)
                            ? R.string.context_menu_remove_favorites
                            : R.string.context_menu_add_favorites)
                    .setOnMenuItemClickListener(contextMenuHandler);
            menu.add(Menu.NONE, R.id.context_menu_quickaccess_add, 2, R.string.context_menu_quickaccess_add)
                    .setOnMenuItemClickListener(contextMenuHandler).setVisible(canAddToQuickAccess);
            menu.add(Menu.NONE, R.id.context_menu_quickaccess_custom_board, 3,
                    R.string.context_menu_quickaccess_custom_board)
                    .setOnMenuItemClickListener(contextMenuHandler);
            if (isSingleboardChan(
                    chansAdapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)))
                menu.findItem(R.id.context_menu_quickaccess_custom_board).setVisible(false);
        }
    });
    chansListDialog.show();
}

From source file:io.mpos.ui.shared.view.SummaryFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (showSendReceiptButton()) {
        menu.add(Menu.NONE, R.id.mpu_send_receipt_action_id, Menu.NONE, R.string.MPUSend)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }// ww  w .  ja  v  a2s  .  com
    super.onCreateOptionsMenu(menu, inflater);
}

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

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

    super.onPrepareOptionsMenu(menu);
    menu.clear();//from  w ww  .  j a va2s  .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.ruesga.rview.MainActivity.java

private void updateAccountCustomFilters() {
    // Remove all custom filters and re-add them
    final DrawerNavigationMenu menu = (DrawerNavigationMenu) mBinding.drawerNavigationView.getMenu();
    int myFiltersGroupIndex = menu.findGroupIndex(R.id.category_my_filters);
    MenuItem group = menu.getItem(myFiltersGroupIndex);
    SubMenu myFiltersSubMenu = group.getSubMenu();
    int count = myFiltersSubMenu.size() - 1;
    for (int i = count; i >= 0; i--) {
        ((DrawerNavigationSubMenu) myFiltersSubMenu).removeItemAt(i);
    }//from w  ww  . j ava2s. c  o m

    mCustomFilters = Preferences.getAccountCustomFilters(this, mAccount);
    if (mCustomFilters != null) {
        int i = 0;
        for (CustomFilter filter : mCustomFilters) {
            int id = MY_FILTERS_GROUP_BASE_ID + i;
            String title = filter.mName + DrawerNavigationView.SEPARATOR + filter.mQuery.toString()
                    + DrawerNavigationView.SEPARATOR + "ic_close";
            MenuItem item = myFiltersSubMenu.add(group.getGroupId(), id, Menu.NONE, title);
            item.setIcon(R.drawable.ic_filter);
            item.setCheckable(true);
            i++;
        }
    }

    menu.setGroupVisible(R.id.category_my_filters,
            !mModel.isAccountExpanded && mCustomFilters != null && !mCustomFilters.isEmpty());
    mBinding.drawerNavigationView.setCheckedItem(mModel.currentNavigationItemId);
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE,
            getString(R.string.order_call_taxi_page_title));
    SpannableString spanString = new SpannableString(item.getTitle().toString());
    spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white
    item.setTitle(spanString);/*from w  ww . ja  v a  2s .  c o m*/
    if (isShowOneKey)
        item.setVisible(true);
    else
        item.setVisible(false);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.alfresco.mobile.android.application.accounts.fragment.AccountDetailsFragment.java

public void getMenu(Menu menu) {
    MenuItem mi;//from  w  ww  . j a  v a 2s .  co  m

    if (acc.getActivation() == null) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_ACCOUNT_EDIT,
                Menu.FIRST + MenuActionItem.MENU_ACCOUNT_EDIT,
                String.format(getString(R.string.account_edit_hint), acc.getDescription()));
        mi.setIcon(R.drawable.ic_edit);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    mi = menu.add(Menu.NONE, MenuActionItem.MENU_ACCOUNT_DELETE,
            Menu.FIRST + MenuActionItem.MENU_ACCOUNT_DELETE,
            String.format(getString(R.string.account_delete_hint), acc.getDescription()));
    mi.setIcon(R.drawable.ic_delete);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

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  w  ww .  ja  v  a2  s  .  c om*/
    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.menu.MainMenuFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*w w w  .ja  v  a 2s  .c  o  m*/

    if (showOperationsMenu) {
        MenuItem mi = menu.add(Menu.NONE, R.id.menu_notifications, Menu.FIRST, R.string.notifications);
        mi.setIcon(R.drawable.ic_events_dark);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
}

From source file:org.fdroid.fdroid.AppDetails.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.clear();//from   w w w.ja  va  2s  .  c o m
    if (app == null) {
        return true;
    }

    if (packageManager.getLaunchIntentForPackage(app.packageName) != null && app.canAndWantToUpdate()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch).setIcon(R.drawable.ic_play_arrow_white),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    }

    if (app.isInstalled()) {
        MenuItemCompat.setShowAsAction(
                menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall).setIcon(R.drawable.ic_delete_white),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    }

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

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

    if (app.hasUpdates()) {
        menu.add(Menu.NONE, IGNORETHIS, 2, R.string.menu_ignore_this)
                .setIcon(R.drawable.ic_do_not_disturb_white).setCheckable(true)
                .setChecked(app.ignoreThisUpdate >= app.suggestedVersionCode);
    }

    // Ignore on devices without Bluetooth
    if (app.isInstalled() && fdroidApp.bluetoothAdapter != null) {
        menu.add(Menu.NONE, SEND_VIA_BLUETOOTH, 3, R.string.send_via_bluetooth)
                .setIcon(R.drawable.ic_bluetooth_white);
    }
    return true;
}