List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:edu.cmu.cylab.starslinger.view.FindContactActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(0, MENU_HELP, 0, R.string.menu_Help).setIcon(R.drawable.ic_action_help); MenuCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); menu.add(0, MENU_ABOUT, 0, R.string.menu_About).setIcon(android.R.drawable.ic_menu_info_details); menu.add(0, MENU_FEEDBACK, 0, R.string.menu_sendFeedback).setIcon(android.R.drawable.ic_menu_send); return true;//from ww w .ja va 2s . c o m }
From source file:com.jecelyin.android.file_explorer.FileExplorerAction.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste); pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); pasteMenu.setEnabled(fileClipboard.canPaste()); renameMenu = menu.add(0, R.id.rename, 0, R.string.rename); renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); shareMenu = menu.add(0, R.id.share, 0, R.string.share); shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); shareActionProvider = new ShareActionProvider(context); shareActionProvider.setOnShareTargetSelectedListener(this); MenuItemCompat.setActionProvider(shareMenu, shareActionProvider); menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true;//from www. j a va2 s . c om }
From source file:net.openfiretechnologies.veloxcontrol.github.GithubViewer.java
/** * this is the only method called right before every display of the menu * here we choose what dynamic content to display for the menu *///from www. ja v a2 s .c om public void onPrepareOptionsMenu(Menu menu) { // remove old menu items menu.clear(); // cant change branch if we are not viewing a project folder's commits if (ARE_IN_PROJECT_PATH) menu.add(0, MENU_ID_COMMITLOG, 0, getString(R.string.changelog_menu_commitlog_title)); else menu.add(0, MENU_ID_PACKAGES, 0, getString(R.string.changelog_menu_projects_title)); }
From source file:it.unibs.sandroide.lib.beacon.ui.BeaconTagActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();/* www . j av a 2s. co m*/ menu.add(0, MENU_ADD, Menu.NONE, "Load").setIcon(android.R.drawable.ic_menu_add); menu.add(0, MENU_LIST, Menu.NONE, "Save").setIcon(android.R.drawable.ic_menu_upload); return super.onPrepareOptionsMenu(menu); }
From source file:net.reichholf.dreamdroid.activities.VirtualRemoteActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_LAYOUT, 0, getText(R.string.quickzap)) .setIcon(android.R.drawable.ic_menu_always_landscape_portrait); return true;// w ww .j a va 2s.c om }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.LibraryCursorAdapter.java
public void getMenu(Menu menu, File f) { MenuItem mi;//w ww . j a va 2 s. c om if (f.isFile()) { mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST, R.string.share); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } if (f.canWrite() && downloadPath != null && f.getPath().startsWith(downloadPath)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:com.octade.droid.ilesansfil.IleSansFil.java
public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, MENU_LOCATION, 0, getResources().getString(R.string.menuGpsOn)).setCheckable(true) .setChecked(true);/*from w ww . j a v a 2s .c o m*/ // menu.add(0, MENU_SETTINGS, 1, "Settings"); menu.add(0, MENU_ABOUT, 2, getResources().getString(R.string.menuAbout)); menu.add(0, MENU_TOGGLE_PIN, 3, getResources().getString(R.string.menuPinOn)).setCheckable(true) .setChecked(true); return true; }
From source file:com.crystal.CrystalBeanWallpapers.Wallpaper.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, MENU_APPLY, 0, R.string.action_apply).setIcon(android.R.drawable.ic_menu_set_as) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return super.onCreateOptionsMenu(menu); }
From source file:com.mifos.mifosxdroid.online.loancharge.LoanChargeFragment.java
@SuppressWarnings("deprecation") @Override/*from w w w . java 2 s . c o m*/ public void onPrepareOptionsMenu(Menu menu) { menu.clear(); MenuItem menuItemAddNewLoanCharge = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_LOAN_CHARGES, Menu.NONE, getString(R.string.add_new)); menuItemAddNewLoanCharge.setIcon(getResources().getDrawable(R.drawable.ic_add_white_24dp)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) menuItemAddNewLoanCharge.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); super.onPrepareOptionsMenu(menu); }
From source file:com.cranberrygame.phonegap.plugin.OptionsMenu.java
@Override public Object onMessage(String id, Object data) { //https://github.com/dpogue/cordova-plugin-cambie/blob/master/src/android/Cambie.java //http://stackoverflow.com/questions/22403984/get-oncreateoptionsmenu-in-cordova-plugin //https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L140 if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) { Menu menu = (Menu) data; if (this.menus != null) { menu.clear();/* ww w. ja v a 2s . c o m*/ String[] _menus = this.menus.split(","); for (int i = 0; i < _menus.length; i++) { menu.add(0, i, 0, _menus[i]); } } } else if (id.equals("onOptionsItemSelected")) { MenuItem item = (MenuItem) data; webView.loadUrl(String.format("javascript:cordova.fireDocumentEvent('onMenuSelected', {'menu': '%s'});", item.getTitle())); } return null; }