List of usage examples for android.view Menu add
public MenuItem add(int groupId, int itemId, int order, @StringRes int titleRes);
From source file:at.jclehner.rxdroid.ui.DoseLogFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { final int titleResId = isAllCollapsed() ? R.string._title_expand : R.string._title_collapse; MenuItem item = menu.add(0, MENU_COLLAPSE_EXPAND, 0, titleResId) .setIcon(isAllCollapsed() ? R.drawable.ic_action_expand_white : R.drawable.ic_action_collapse_white) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from w w w. j av a 2s . c o m public boolean onMenuItemClick(MenuItem item) { final boolean isAllCollapsed = isAllCollapsed(); if (isAllCollapsed) expandAll(true); else collapseAll(); Settings.putBoolean(Keys.LOG_IS_ALL_COLLAPSED, !isAllCollapsed); //invalidateOptionsMenu(); return true; } }); item.setVisible(!getListAdapter().isEmpty()); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.core.vmfiveadnetwork.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_ABOUT, 0, "About"); menu.add(0, MENU_CLEAR_RESOURCE_CACHE, 0, "Clear File Cache"); menu.add(0, MENU_CLEAR_CONNECTION_CACHE, 0, "Clear Connection Cache"); menu.add(0, MENU_CLEAR_PREFERENCES_CACHE, 0, "Clear Preferences Cache"); menu.add(0, MENU_EXIT, 0, "Exit"); return true;// w w w.ja v a 2 s .c o m }
From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraImageFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem menuItem_Share = menu.findItem(R.id.action_share); shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share); shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); if (showStar) { MenuItem menuItem_Star = menu.add(0, MENU_ITEM_STAR, menu.size(), R.string.description_star); MenuItemCompat.setShowAsAction(menuItem_Star, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); if (mIsStarred) { menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star_on); } else {/*from ww w . ja v a2 s . c o m*/ menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star); } } }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
public void showAudioPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio); final MenuItem backgroundAudioItem = menu.findItem(0); backgroundAudioItem.setCheckable(true); backgroundAudioItem.setChecked(enableBackgroundAudio); OnMenuItemClickListener clickListener = new OnMenuItemClickListener() { @Override//from ww w. ja v a 2 s. c o m public boolean onMenuItemClick(MenuItem item) { if (item == backgroundAudioItem) { enableBackgroundAudio = !item.isChecked(); return true; } return false; } }; configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO); popup.show(); }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
public void showVerboseLogPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal); menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose); menu.setGroupCheckable(Menu.NONE, true, true); menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/* ww w .java 2s .c o m*/ public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == 0) { VerboseLogUtil.setEnableAllTags(false); } else { VerboseLogUtil.setEnableAllTags(true); } return true; } }); popup.show(); }
From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsActionMode.java
protected void getMenu(FragmentActivity activity, Menu menu) { if (selectedItems.isEmpty() || selectedItems.size() > 1) { return;// w ww.j a va 2 s . c om } MenuItem mi; Node node = getCurrentItem(); if (node == null) { return; } if (node instanceof NodeSyncPlaceHolder) { return; } boolean isRestrict = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE); if (node.isDocument()) { if (((Document) node).getContentStreamLength() > 0 && !isRestrict && ConfigurableActionHelper .isVisible(getActivity(), getAccount(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD)) { mi = menu.add(Menu.NONE, R.id.menu_action_download, Menu.FIRST, R.string.download); mi.setIcon(R.drawable.ic_download_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (((Document) node).isLatestVersion() && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_UPDATE)) { mi = menu.add(Menu.NONE, R.id.menu_action_update, Menu.FIRST + 130, R.string.update); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!(SessionUtils.getSession(activity) instanceof CloudSession) && ConfigurableActionHelper .isVisible(getActivity(), getAccount(), ConfigurableActionHelper.ACTION_NODE_REVIEW)) { mi = menu.add(Menu.NONE, R.id.menu_workflow_add, Menu.FIRST + 500, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_EDIT)) { mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.edit); mi.setIcon(R.drawable.ic_properties); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_DELETE)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
From source file:org.alfresco.mobile.android.application.fragments.properties.DetailsFragment.java
public static void getMenu(AlfrescoSession session, Activity activity, Menu menu, Node node, boolean actionMode) { MenuItem mi;//from w w w . j ava 2 s . c o m if (node == null) { return; } if (node instanceof NodeSyncPlaceHolder) { return; } boolean isRestrict = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE); if (node.isDocument()) { if (((Document) node).getContentStreamLength() > 0 && !isRestrict) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DOWNLOAD, Menu.FIRST + MenuActionItem.MENU_DOWNLOAD, R.string.download); mi.setIcon(R.drawable.ic_download_dark); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (((Document) node).isLatestVersion() && ((DocumentImpl) node).hasAllowableAction(Action.CAN_SET_CONTENT_STREAM.value())) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_UPDATE, Menu.FIRST + MenuActionItem.MENU_UPDATE, R.string.update); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!(session instanceof CloudSession)) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_WORKFLOW_ADD, Menu.FIRST + MenuActionItem.MENU_WORKFLOW_ADD, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } if (session.getServiceRegistry().getDocumentFolderService().getPermissions(node).canEdit()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_EDIT, Menu.FIRST + MenuActionItem.MENU_EDIT, R.string.edit); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (session.getServiceRegistry().getDocumentFolderService().getPermissions(node).canDelete()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DELETE, 1000 + MenuActionItem.MENU_DELETE, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!DisplayUtils.hasCentralPane(activity)) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMMENT, Menu.FIRST + MenuActionItem.MENU_COMMENT, R.string.comments); mi.setIcon(R.drawable.ic_comment); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); if (node.isDocument()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_VERSION_HISTORY, Menu.FIRST + MenuActionItem.MENU_VERSION_HISTORY, R.string.version_history); mi.setIcon(R.drawable.ic_menu_recent_history); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mi = menu.add(Menu.NONE, MenuActionItem.MENU_TAGS, Menu.FIRST + MenuActionItem.MENU_TAGS, R.string.tags); mi.setIcon(R.drawable.mime_tags); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
From source file:com.guipenedo.pokeradar.activities.MapsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem settings = menu.add(0, 0, 0, R.string.settings).setIcon(R.drawable.cog); settings.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/* w w w .jav a 2s.c om*/ public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), MainSettingsActivity.class); startActivity(i); return true; } }); MenuItem info = menu.add(0, 0, 0, R.string.about).setIcon(R.drawable.info_circle); info.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), AboutActivity.class); startActivity(i); return true; } }); info.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem logOut = menu.add(0, 0, 0, R.string.log_out).setIcon(R.drawable.sign_out); logOut.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Utils.relog(MapsActivity.this); return true; } }); logOut.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }
From source file:com.acrylicgoat.scrumnotes.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); readDB();/*w ww .j a va 2 s . c o m*/ if (devs != null && devs.size() > 0) { for (int i = 0; i < devs.size(); i++) { Developer dev = (Developer) devs.get(i); if (i == 0 && (currentOwner == null || currentOwner.equals(""))) { currentOwner = dev.getName(); } menu.add(0, MENUITEM, 0, dev.getName()).setIcon(R.drawable.dev); } } getOwner(currentOwner); return true; }
From source file:fm.smart.r1.activity.ItemActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, CREATE_EXAMPLE_ID, 0, R.string.menu_create_example).setIcon(android.R.drawable.ic_menu_add); // remove until we have it working ... // menu.add(0, CREATE_SOUND_ID, 0, R.string.menu_create_sound).setIcon( // R.drawable.microphone); menu.add(0, ADD_TO_LIST_ID, 0, R.string.menu_add_to_list).setIcon(android.R.drawable.ic_menu_add); return true;/*from w w w.j a v a 2 s . c om*/ }