List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:com.example.android.pantry.scanner.BarcodeScannerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem menuItem;//from w w w .j ava 2s .c o m if (mFlash) { menuItem = menu.add(Menu.NONE, R.id.menu_flash, 0, R.string.flash_on); } else { menuItem = menu.add(Menu.NONE, R.id.menu_flash, 0, R.string.flash_off); } MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER); if (mAutoFocus) { menuItem = menu.add(Menu.NONE, R.id.menu_auto_focus, 0, R.string.auto_focus_on); } else { menuItem = menu.add(Menu.NONE, R.id.menu_auto_focus, 0, R.string.auto_focus_off); } MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER); menuItem = menu.add(Menu.NONE, R.id.menu_formats, 0, R.string.formats); MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER); menuItem = menu.add(Menu.NONE, R.id.menu_camera_selector, 0, R.string.select_camera); MenuItemCompat.setShowAsAction(menuItem, MenuItem.SHOW_AS_ACTION_NEVER); return super.onCreateOptionsMenu(menu); }
From source file:org.alfresco.mobile.android.application.fragments.help.HelpDialogFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); if (!MenuFragmentHelper.canDisplayFragmentMenu(getActivity())) { return;/*from w ww . j a v a 2s . c om*/ } menu.clear(); refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh); refreshIcon.setIcon(R.drawable.ic_refresh); refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }
From source file:com.kentli.cycletrack.RecordingActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, MENU_HELP, 0, "Help and FAQ").setIcon(android.R.drawable.ic_menu_help); menu.add(0, MENU_USER_INFO, 0, "Edit User Info").setIcon(android.R.drawable.ic_menu_edit); menu.add(0, MENU_HISTORY, 0, "Trip History").setIcon(android.R.drawable.ic_menu_recent_history); return true;/*from www. java 2 s. c om*/ }
From source file:com.example.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity_screen_slide, menu); menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0); // Add either a "next" or "finish" button to the action bar, depending on which page // is currently selected. MenuItem item = menu.add(Menu.NONE, R.id.action_previous, Menu.NONE, (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? "Finalizar" : "Siguiente"); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;/*from w ww . j a v a2 s .c o m*/ }
From source file:edu.stanford.mobisocial.dungbeetle.ImageGalleryActivity.java
public boolean onPreparePanel(int featureId, View view, Menu menu) { menu.clear();/*from w ww. ja va 2 s .c o m*/ menu.add(0, MENU_EDIT, 0, "Edit"); menu.add(0, MENU_SAVE, 0, "Save to SD Card"); menu.add(0, MENU_SET_PROFILE, 0, "Set as Profile"); return true; }
From source file:edu.cmu.android.restaurant.MapFragment.java
/** * Menu - include 4 items 1. Camera : click to make a photo 2. Coupon : * click to find the coupon of the restaurant 3. About : The developer's * information/*from w w w. java2 s . c o m*/ * */ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); // 1.group, 2.ID, 3.order, 4.txt menu.add(Menu.NONE, Menu.FIRST + 1, 1, "Camera").setIcon(android.R.drawable.ic_menu_camera); menu.add(Menu.NONE, Menu.FIRST + 2, 2, "Coupon").setIcon(R.drawable.ic_menu_emoticons); menu.add(Menu.NONE, Menu.FIRST + 3, 3, "About").setIcon(android.R.drawable.ic_menu_myplaces); }
From source file:net.amdroid.metrosp.MetroSP.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_PREFS, 0, getResources().getText(R.string.preferences)); MenuItem item = menu.findItem(MENU_PREFS); item.setIcon(R.drawable.ic_menu_preferences); return true;//w w w . ja v a 2 s .com }
From source file:net.gromgull.android.bibsonomyposter.BibsonomyPosterActivity.java
/** * Called when your activity's options menu needs to be created. *//*from w ww . ja v a 2 s .co m*/ @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // We are going to create two menus. Note that we assign them // unique integer IDs, labels from our string resources, and // given them shortcuts. menu.add(0, SAVE_ID, 0, R.string.save).setShortcut('0', 's'); return true; }
From source file:com.gsc.testing.espresso.espressotesting.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // getMenuInflater().inflate(R.menu.activity_screen_slide, menu); menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0); // Add either a "next" or "finish" button to the action bar, depending on which page // is currently selected. MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE, (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish : R.string.action_next); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;/*ww w.j a va 2s .co m*/ }
From source file:bander.notepad.NoteEditAppCompat.java
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); if (mState == STATE_EDIT) { menu.add(0, REVERT_ID, 0, R.string.menu_revert).setIcon(android.R.drawable.ic_menu_revert); menu.add(0, DELETE_ID, 0, R.string.menu_delete).setIcon(android.R.drawable.ic_menu_delete); }/* w w w . jav a2 s .c o m*/ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean theme = preferences.getBoolean("darkAppCompatTheme", false); if (theme) { // Light theme, dark icons, but GB theme always has light icons. menu.add(0, SEND_ID, 0, R.string.menu_send) .setIcon(IconTintFactory.setLightMaterialColor(R.drawable.ic_share_black_48dp, NoteEditAppCompat.this)) .setShowAsActionFlags( MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } else { // Dark theme, light icons. menu.add(0, SEND_ID, 0, R.string.menu_send) .setIcon(IconTintFactory.setDarkMaterialColor(R.drawable.ic_share_black_48dp, NoteEditAppCompat.this)) .setShowAsActionFlags( MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } return result; }