List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:net.cloudpath.xpressconnect.screens.ScreenBase.java
public boolean onCreateOptionsMenu(Menu paramMenu) { if ((paramMenu == null) || (this.mShowNoParentMenu == true)) return super.onCreateOptionsMenu(paramMenu); if ((this.mShowAboutMenu) && (!this.mGlobals.getRunningAsLibrary())) paramMenu.add(0, 1, 0, this.mParcelHelper.getIdentifier("xpc_about", "string")); if (this.mShowLogsMenu) paramMenu.add(0, 2, 0, this.mParcelHelper.getIdentifier("xpc_show_log_title", "string")); if (this.mShowHelpdeskMenu) paramMenu.add(0, 3, 0, this.mParcelHelper.getIdentifier("xpc_show_helpdesk", "string")); if (this.mShowEmailLogsMenu) paramMenu.add(0, 4, 0, this.mParcelHelper.getIdentifier("xpc_email_log", "string")); if (this.mShowStartOverMenu) paramMenu.add(0, 5, 0, this.mParcelHelper.getIdentifier("xpc_start_over", "string")); if (this.mShowQuitMenu) paramMenu.add(0, 6, 0, this.mParcelHelper.getIdentifier("xpc_quit", "string")); return super.onCreateOptionsMenu(paramMenu); }/*w ww . ja va 2 s . co m*/
From source file:com.androzic.waypoint.WaypointList.java
@Override public void onPrepareOptionsMenu(final Menu menu) { Androzic application = Androzic.getApplication(); MenuItem sortItem = menu.findItem(mSortMode == 0 ? R.id.action_sort_alpha : R.id.action_sort_size); sortItem.setChecked(true);//from w w w . j ava 2s. co m Editor editor = PreferenceManager.getDefaultSharedPreferences(application).edit(); editor.putInt(getString(R.string.wpt_sort), mSortMode); editor.commit(); List<WaypointSet> sets = application.getWaypointSets(); if (sets.size() > 1) { menu.setGroupVisible(R.id.group_sets, true); menu.removeGroup(R.id.group_sets); for (int i = 1; i < sets.size(); i++) menu.add(R.id.group_sets, i, Menu.NONE, sets.get(i).name).setChecked(true); menu.setGroupCheckable(R.id.group_sets, true, false); } }
From source file:com.yeldi.yeldibazaar.AppDetails.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.clear();/*from ww w . j a va 2 s .c o m*/ if (app == null) return true; DB.Apk curver = app.getCurrentVersion(); if (app.hasUpdates == true) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(R.drawable.ic_menu_refresh), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } if (app.installedVersion == null && curver != null) { 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.installedVersion != null) { 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); if (app.detail_webURL.length() > 0) { menu.add(Menu.NONE, WEBSITE, 2, R.string.menu_website).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_trackerURL.length() > 0) { menu.add(Menu.NONE, ISSUES, 3, R.string.menu_issues).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_sourceURL.length() > 0) { menu.add(Menu.NONE, SOURCE, 4, R.string.menu_source).setIcon(android.R.drawable.ic_menu_view); } menu.add(Menu.NONE, MARKET, 5, R.string.menu_market).setIcon(android.R.drawable.ic_menu_view); if (app.detail_bitcoinAddr != null) { menu.add(Menu.NONE, BITCOIN, 6, R.string.menu_bitcoin).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_flattrID != null) { menu.add(Menu.NONE, FLATTR, 7, R.string.menu_flattr).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_donateURL != null) { menu.add(Menu.NONE, DONATE, 8, R.string.menu_donate).setIcon(android.R.drawable.ic_menu_view); } return true; }
From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java
@Subscribe(threadMode = ThreadMode.MAIN) public void onPleaseInitializeDrawer(PleaseInitializeDrawer event) { Timber.d("initializing drawer with poiType"); if (filtersItemList == null) { filtersItemList = new ArrayList<>(); }/*from ww w . jav a2 s . c o m*/ List<PoiType> poiTypes = event.getPoiTypes(); poiTypesHidden = event.getPoiTypeHidden(); poiAccessibilityTypesHidden = new ArrayList<>(); filters.clear(); for (PoiType poiType : poiTypes) { Long id = poiType.getId(); filters.add(new PoiTypeFilter(poiType.getName(), id, poiType.getIcon(), !poiTypesHidden.contains(id))); } Collections.sort(filters); Menu menu = filterView.getMenu(); int order = 1; for (PoiTypeFilter poiTypeFilter : filters) { PoiTypeFilter nextPoiTypeFilter = null; if (order < filters.size()) { nextPoiTypeFilter = filters.get(order); } // Add only menu if not present if (menu.findItem(poiTypeFilter.getPoiTypeId().intValue()) == null) { filtersItemList.add(menu .add(Menu.NONE, poiTypeFilter.getPoiTypeId().intValue(), (nextPoiTypeFilter != null ? (poiTypeFilter.compareTo(nextPoiTypeFilter) > 0 ? order - 1 : order) : order), poiTypeFilter.getPoiTypeName()) .setChecked(poiTypeFilter.isActive()) .setIcon(bitmapHandler.getDrawable(poiTypeFilter.getPoiTypeIconName()))); } order++; } // Remove only filter removed by user if (filters.size() < filtersItemList.size()) { List<MenuItem> temp = new ArrayList<>(filters.size()); for (MenuItem menuItem : filtersItemList) { PoiTypeFilter poiTypeFilter = new PoiTypeFilter("", (long) menuItem.getItemId(), "", true); if (!filters.contains(poiTypeFilter)) { menu.removeItem(poiTypeFilter.getPoiTypeId().intValue()); } else { temp.add(menuItem); } } filtersItemList.clear(); filtersItemList.addAll(temp); temp.clear(); } selectAllMenuItem.setChecked(poiTypesHidden.isEmpty()); }
From source file:cm.aptoide.pt.ManageRepos.java
public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(Menu.NONE, EnumOptionsMenu.ADD_REPO.ordinal(), 1, R.string.add_repo) .setIcon(R.drawable.ic_menu_add); menu.add(Menu.NONE, EnumOptionsMenu.EDIT_REPO.ordinal(), 2, R.string.edit_repo) .setIcon(R.drawable.ic_menu_edit); menu.add(Menu.NONE, EnumOptionsMenu.REMOVE_REPO.ordinal(), 3, R.string.remove_repo) .setIcon(R.drawable.ic_menu_close_clear_cancel); return true;/*from w w w . jav a 2 s . c o m*/ }
From source file:com.markuspage.android.atimetracker.Tasks.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, ADD_TASK, 0, R.string.add_task_title).setIcon(android.R.drawable.ic_menu_add); menu.add(0, REPORT, 1, R.string.generate_report_title).setIcon(android.R.drawable.ic_menu_week); menu.add(0, MORE, 2, R.string.more).setIcon(android.R.drawable.ic_menu_more); return true;/*www. j a v a 2 s.c o m*/ }
From source file:gov.wa.wsdot.android.wsdot.ui.TrafficMapActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();/* w w w . ja va 2 s . c om*/ getMenuInflater().inflate(R.menu.traffic, menu); if (showCameras) { menu.getItem(0).setTitle("Hide Cameras"); } else { menu.getItem(0).setTitle("Show Cameras"); } /** * Check if current location is within a lat/lon bounding box surrounding * the greater Seattle area. */ try { LatLng center = map.getCameraPosition().target; if (inPolygon(seattleArea, center.latitude, center.longitude)) { MenuItem menuItem_Alerts = menu.add(0, MENU_ITEM_SEATTLE_ALERTS, menu.size(), "Seattle Alerts") .setIcon(R.drawable.ic_menu_alerts); MenuItemCompat.setShowAsAction(menuItem_Alerts, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItem menuItem_Lanes = menu.add(0, MENU_ITEM_EXPRESS_LANES, menu.size(), "Express Lanes"); MenuItemCompat.setShowAsAction(menuItem_Lanes, MenuItemCompat.SHOW_AS_ACTION_NEVER); } } catch (NullPointerException e) { Log.e(TAG, "Error getting LatLng center"); } return super.onPrepareOptionsMenu(menu); }
From source file:com.pdftron.pdf.controls.UserBookmarkDialogFragment.java
public void onShowPopupMenu(final int position, View anchor) { PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); Menu menu = popupMenu.getMenu(); final UserBookmarkItem bItem = mBookmarkViewAdapter.getItem(position); String[] menuItems = getResources().getStringArray(R.array.user_bookmark_dialog_context_menu); menu.add(Menu.NONE, CONTEXT_MENU_EDIT_ITEM, CONTEXT_MENU_EDIT_ITEM, menuItems[CONTEXT_MENU_EDIT_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM, CONTEXT_MENU_DELETE_ITEM, menuItems[CONTEXT_MENU_DELETE_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ALL, CONTEXT_MENU_DELETE_ALL, menuItems[CONTEXT_MENU_DELETE_ALL]); MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override//from ww w . j a va 2 s. com public boolean onMenuItemClick(MenuItem item) { onPopupItemSelected(item, position); return true; } }; menu.getItem(CONTEXT_MENU_EDIT_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ALL).setOnMenuItemClickListener(listener); popupMenu.show(); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, MENU_EDIT_NAME, Menu.NONE, R.string.rom_menu_edit_name); menu.add(0, MENU_CHANGE_IMAGE, Menu.NONE, R.string.rom_menu_change_image); menu.add(0, MENU_RESET_IMAGE, Menu.NONE, R.string.rom_menu_reset_image); return true;/*from w w w . jav a 2 s. co m*/ }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;/*from w ww . j a va2s .c om*/ } if (getActivity() instanceof MainActivity) { getMenu(alfSession, menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, MenuActionItem.MENU_DISPLAY_GALLERY, Menu.FIRST + MenuActionItem.MENU_DISPLAY_GALLERY, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity) { Permissions permission = alfSession.getServiceRegistry().getDocumentFolderService() .getPermissions(parentFolder); if (permission.canAddChildren()) { MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER, Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create); mi.setIcon(R.drawable.ic_add_folder); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } // Uncomment for enabling view switcher /* * displayMenuItem = menu.add(Menu.NONE, * MenuActionItem.MENU_DISPLAY_ITEMS, Menu.FIRST + * MenuActionItem.MENU_DISPLAY_ITEMS, R.string.display_views); switch * (displayMode) { case DISPLAY_LIST: * displayMenuItem.setIcon(R.drawable.ic_action_list); break; case * DISPLAY_LIST_LARGE: * displayMenuItem.setIcon(R.drawable.ic_action_tiles_small); break; * case DISPLAY_GRID: * displayMenuItem.setIcon(R.drawable.ic_action_list_2); break; default: * break; } * displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); */ }