List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); MenuItem item;// w w w . j ava 2 s .c o m item = menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist) .setIcon(R.drawable.ic_list_24dp).setAlphabeticShortcut('P'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); item = menu.add(ContextMenu.NONE, MENU_STATS, ContextMenu.NONE, R.string.menu_statistics) .setIcon(R.drawable.ic_graph_24dp).setAlphabeticShortcut('S'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); item = menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack) .setIcon(R.drawable.ic_share_24dp).setAlphabeticShortcut('I'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_LAYERS, ContextMenu.NONE, R.string.menu_showLayers) .setIcon(R.drawable.ic_layers_24dp).setAlphabeticShortcut('L'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_NOTE, ContextMenu.NONE, R.string.menu_insertnote) .setIcon(R.drawable.ic_pin_drop_24dp); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_SETTINGS, ContextMenu.NONE, R.string.menu_settings) .setIcon(R.drawable.ic_menu_preferences).setAlphabeticShortcut('C'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER); return result; }
From source file:com.android.settings.applications.CanBeOnSdCardChecker.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mOptionsMenu = menu;// w w w .j a v a 2 s . c o m // note: icons removed for now because the cause the new action // bar UI to be very confusing. menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha) //.setIcon(android.R.drawable.ic_menu_sort_alphabetically) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size) //.setIcon(android.R.drawable.ic_menu_sort_by_size) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, RESET_APP_PREFERENCES, 4, R.string.reset_app_preferences) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (!Utils.isRestrictedProfile(getActivity())) { menu.add(0, SHOW_PROTECTED_APPS, 5, R.string.protected_apps) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } updateOptionsMenu(); }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; MenuItem itemUpdate = menu.add(Menu.NONE, R.id.menu_update, 1, R.string.menu_update); MenuItem itemSave = menu.add(Menu.NONE, R.id.menu_save_attachment, 2, R.string.menu_save_attachment); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { itemUpdate.setIcon(ThemeUtils.getActionbarIcon(getTheme(), getResources(), R.attr.actionRefresh)); itemSave.setIcon(ThemeUtils.getActionbarIcon(getTheme(), getResources(), R.attr.actionSave)); CompatibilityImpl.setShowAsActionIfRoom(itemUpdate); CompatibilityImpl.setShowAsActionIfRoom(itemSave); } else {/*from w w w . j a va2 s .c om*/ itemUpdate.setIcon(R.drawable.ic_menu_refresh); itemSave.setIcon(android.R.drawable.ic_menu_save); } menu.add(Menu.NONE, R.id.menu_open_external, 3, R.string.menu_open).setIcon(R.drawable.ic_menu_set_as); menu.add(Menu.NONE, R.id.menu_share, 4, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share); menu.add(Menu.NONE, R.id.menu_share_link, 5, R.string.menu_share_link) .setIcon(android.R.drawable.ic_menu_share); menu.add(Menu.NONE, R.id.menu_reverse_search, 6, R.string.menu_reverse_search) .setIcon(android.R.drawable.ic_menu_search); menu.add(Menu.NONE, R.id.menu_open_browser, 7, R.string.menu_open_browser) .setIcon(R.drawable.ic_menu_browser); updateMenu(); return true; }
From source file:net.movelab.cmlibrary.MapMyData.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); menu.clear();//from www . j a v a2 s . co m menu.add(0, LOCATE_NOW, Menu.NONE, R.string.menu_locate_now); menu.add(0, SETTINGS, Menu.NONE, R.string.menu_settings); menu.add(0, CENTER, Menu.NONE, R.string.menu_center_map); menu.add(0, SAVE_MAP, Menu.NONE, R.string.menu_map_save); menu.add(0, SHARE_MAP, Menu.NONE, R.string.menu_map_share); menu.add(0, LIFELINE, Menu.NONE, R.string.lifeline_button); menu.add(0, LIST_DATA, Menu.NONE, R.string.list_data_button); menu.add(0, SAVE_CSV, Menu.NONE, R.string.save_data_button); menu.add(0, FLUSH_GPS, Menu.NONE, R.string.menu_flush_gps); menu.add(0, RATE, Menu.NONE, R.string.menu_rate); menu.add(0, SHARE, Menu.NONE, R.string.menu_share); if (shareData) menu.add(0, ASP, Menu.NONE, R.string.menu_asp); menu.add(0, ABOUT, Menu.NONE, R.string.about); return true; }
From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java
@Override public void onCreateOptionsMenu(Menu menu) { menu.add(0, OPTIONS_MENU_ADD_POST, 0, R.string.action_add_post).setIcon(obtainIcon(R.attr.actionAddPost)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_search); menu.add(0, OPTIONS_MENU_GALLERY, 0, R.string.action_gallery); menu.add(0, OPTIONS_MENU_SELECT, 0, R.string.action_select); menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh).setIcon(obtainIcon(R.attr.actionRefresh)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance); SubMenu threadOptions = menu.addSubMenu(0, OPTIONS_MENU_THREAD_OPTIONS, 0, R.string.action_thread_options); menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_TEXT, 0, R.string.action_add_to_favorites); menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_TEXT, 0, R.string.action_remove_from_favorites); menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_ICON, 0, R.string.action_add_to_favorites) .setIcon(obtainIcon(R.attr.actionAddToFavorites)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_ICON, 0, R.string.action_remove_from_favorites) .setIcon(obtainIcon(R.attr.actionRemoveFromFavorites)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0, OPTIONS_MENU_OPEN_ORIGINAL_THREAD, 0, R.string.action_open_the_original); menu.add(0, OPTIONS_MENU_ARCHIVE, 0, R.string.action_archive_add); threadOptions.add(0, THREAD_OPTIONS_MENU_RELOAD, 0, R.string.action_reload); threadOptions.add(0, THREAD_OPTIONS_MENU_AUTO_REFRESH, 0, R.string.action_auto_refresh).setCheckable(true); threadOptions.add(0, THREAD_OPTIONS_MENU_HIDDEN_POSTS, 0, R.string.action_hidden_posts); threadOptions.add(0, THREAD_OPTIONS_MENU_CLEAR_DELETED, 0, R.string.action_clear_deleted); threadOptions.add(0, THREAD_OPTIONS_MENU_SUMMARY, 0, R.string.action_summary); }
From source file:com.audiokernel.euphonyrmt.fragments.NowPlayingFragment.java
/** * Run during fragment initialization, this sets up the cover art popup menu and the coverArt * ImageView.// w ww .ja v a2 s . c o m * * @param view The view to setup the coverArt ImageView in. * @return The resulting ImageView. */ private ImageView getCoverArt(final View view) { final ImageView coverArt = (ImageView) view.findViewById(R.id.albumCover); final PopupMenu coverMenu = new PopupMenu(mActivity, coverArt); final Menu menu = coverMenu.getMenu(); coverArt.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { scrollToNowPlaying(); } }); menu.add(Menu.NONE, POPUP_COVER_BLACKLIST, Menu.NONE, R.string.otherCover); menu.add(Menu.NONE, POPUP_COVER_SELECTIVE_CLEAN, Menu.NONE, R.string.resetCover); coverMenu.setOnMenuItemClickListener(this); coverArt.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(final View v) { final boolean isConsumed; if (mCurrentSong != null) { menu.setGroupVisible(Menu.NONE, new AlbumInfo(mCurrentSong).isValid()); coverMenu.show(); isConsumed = true; } else { isConsumed = false; } return isConsumed; } }); return coverArt; }
From source file:com.grarak.kerneladiutor.activities.NavigationActivity.java
private void appendFragments(boolean setShortcuts) { sActualFragments.clear();/* w w w . ja v a 2 s. co m*/ Menu menu = mNavigationView.getMenu(); menu.clear(); SubMenu lastSubMenu = null; for (NavigationFragment navigationFragment : sFragments) { Fragment fragment = navigationFragment.mFragment; int id = navigationFragment.mId; Drawable drawable = ContextCompat.getDrawable(this, Utils.DONATED && Prefs.getBoolean("section_icons", false, this) && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable : R.drawable.ic_blank); if (fragment == null) { lastSubMenu = menu.addSubMenu(id); sActualFragments.put(id, null); } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled", true, this)) { MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) : lastSubMenu.add(0, id, 0, id); menuItem.setIcon(drawable); menuItem.setCheckable(true); if (mSelection != 0) { mNavigationView.setCheckedItem(mSelection); } sActualFragments.put(id, fragment); } } if (setShortcuts) { setShortcuts(); } }
From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java
void prepareNowPlayingMenu(final Menu menu) { final boolean isStreaming = mApp.isStreamActive(); final MPD mpd = mApp.oMPDAsyncHelper.oMPD; final MPDStatus mpdStatus = mpd.getStatus(); // Reminder : never disable buttons that are shown as actionbar actions here if (mpd.isConnected()) { if (menu.findItem(CONNECT) != null) { menu.removeItem(CONNECT);/*from www. java2 s . c o m*/ } } else { if (menu.findItem(CONNECT) == null) { menu.add(0, CONNECT, 0, R.string.connect); } } final MenuItem saveItem = menu.findItem(R.id.PLM_Save); final MenuItem clearItem = menu.findItem(R.id.PLM_Clear); if (!mIsDualPaneMode && mNowPlayingPager != null && mNowPlayingPager.getCurrentItem() == 0) { saveItem.setVisible(false); clearItem.setVisible(false); } else { saveItem.setVisible(true); clearItem.setVisible(true); } /** If in streamingMode or persistentNotification don't allow a checkbox in the menu. */ final MenuItem notificationItem = menu.findItem(R.id.GMM_ShowNotification); if (notificationItem != null) { if (isStreaming || mApp.isNotificationPersistent()) { notificationItem.setVisible(false); } else { notificationItem.setVisible(true); } setMenuChecked(notificationItem, mApp.isNotificationActive()); } setMenuChecked(menu.findItem(R.id.GMM_Stream), isStreaming); setMenuChecked(menu.findItem(R.id.GMM_Single), mpdStatus.isSingle()); setMenuChecked(menu.findItem(R.id.GMM_Consume), mpdStatus.isConsume()); }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Creates the menu items /*from w w w .j ava 2s .co m*/ */ @Override public boolean onCreateOptionsMenu(Menu oMenu) { boolean bResult = super.onCreateOptionsMenu(oMenu); m_oMenuItemSave = oMenu.add(0, MENU_SAVE, 0, R.string.Menu_Save).setIcon(android.R.drawable.ic_menu_save); oMenu.add(0, MENU_LOG, 0, R.string.Menu_ShowLog).setIcon(android.R.drawable.ic_menu_view); oMenu.add(0, MENU_RESTART_ENGINE, 0, R.string.Menu_RestartEngine) .setIcon(android.R.drawable.ic_menu_revert); if (CustomizationHelper.getInstance().enablePIN()) { // Only let them change the password when passwords (PINs) are enabled. oMenu.add(0, MENU_CHANGE_PASSWORD, 0, R.string.Menu_Change_Password) .setIcon(android.R.drawable.ic_menu_manage); } if (CustomizationHelper.getInstance().enableAdvancedSettings()) { oMenu.add(0, MENU_ADVANCED, 0, R.string.Menu_Advanced).setIcon(android.R.drawable.ic_menu_compass); } oMenu.add(0, MENU_ABOUT, 0, R.string.Menu_About).setIcon(android.R.drawable.ic_menu_info_details); oMenu.add(0, MENU_APP_CONN_ID, 0, R.string.DeviceIDText); return bResult; }
From source file:nya.miku.wishmaster.ui.GalleryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; MenuItem itemUpdate = menu.add(Menu.NONE, R.id.menu_update, 1, R.string.menu_update); MenuItem itemSave = menu.add(Menu.NONE, R.id.menu_save_attachment, 2, R.string.menu_save_attachment); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { itemUpdate.setIcon(ThemeUtils.getActionbarIcon(getTheme(), getResources(), R.attr.actionRefresh)); itemSave.setIcon(ThemeUtils.getActionbarIcon(getTheme(), getResources(), R.attr.actionSave)); CompatibilityImpl.setShowAsActionIfRoom(itemUpdate); CompatibilityImpl.setShowAsActionIfRoom(itemSave); } else {/*from ww w.jav a 2s .c om*/ itemUpdate.setIcon(R.drawable.ic_menu_refresh); itemSave.setIcon(android.R.drawable.ic_menu_save); } menu.add(Menu.NONE, R.id.menu_open_external, 3, R.string.menu_open).setIcon(R.drawable.ic_menu_set_as); menu.add(Menu.NONE, R.id.menu_share, 4, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share); menu.add(Menu.NONE, R.id.menu_share_link, 5, R.string.menu_share_link) .setIcon(android.R.drawable.ic_menu_share); menu.add(Menu.NONE, R.id.menu_search_google, 6, R.string.menu_search_google) .setIcon(android.R.drawable.ic_menu_search); menu.add(Menu.NONE, R.id.menu_open_browser, 7, R.string.menu_open_browser) .setIcon(R.drawable.ic_menu_browser); updateMenu(); return true; }