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.mifos.mifosxdroid.online.clientdetails.ClientDetailsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear();/*from w ww. j a va 2 s . c o m*/ if (isClientActive) { menu.add(Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_CLIENTS_NAME); menu.add(Menu.NONE, MENU_ITEM_PIN_POINT, Menu.NONE, getString(R.string.pinpoint)); menu.add(Menu.NONE, MENU_ITEM_CLIENT_CHARGES, Menu.NONE, getString(R.string.charges)); menu.add(Menu.NONE, MENU_ITEM_ADD_SAVINGS_ACCOUNT, Menu.NONE, getString(R.string.savings_account)); menu.add(Menu.NONE, MENU_ITEM_ADD_LOAN_ACCOUNT, Menu.NONE, getString(R.string.add_loan)); menu.add(Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getString(R.string.documents)); menu.add(Menu.NONE, MENU_ITEM_IDENTIFIERS, Menu.NONE, getString(R.string.identifiers)); menu.add(Menu.NONE, MENU_ITEM_SURVEYS, Menu.NONE, getString(R.string.survey)); } super.onPrepareOptionsMenu(menu); }
From source file:org.alfresco.mobile.android.application.fragments.actions.NodeActions.java
protected void getMenu(FragmentActivity activity, Menu menu) { MenuItem mi;//from w ww. j a v a 2 s . co m SubMenu createMenu; if (selectedFolder.isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_action_download_all, Menu.FIRST, R.string.download); mi.setIcon(R.drawable.ic_download_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD); if (!(SessionUtils.getSession(activity) instanceof CloudSession)) { mi = menu.add(Menu.NONE, R.id.menu_workflow_review_attachments, Menu.FIRST + 500, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_REVIEW); } } // SYNC if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount()) && !SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), parentFolder)) { createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync); createMenu.setIcon(R.drawable.ic_sync_light); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_SYNC); createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync); createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync); } // FAVORITES createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 135, R.string.favorite); createMenu.setIcon(R.drawable.ic_favorite_light); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_FAVORITE); createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite); createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite); // LIKE AlfrescoSession alfSession = SessionUtils.getSession(activity); if (alfSession != null && alfSession.getRepositoryInfo() != null && alfSession.getRepositoryInfo().getCapabilities() != null && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) { createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 150, R.string.like); createMenu.setIcon(R.drawable.ic_like); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_LIKE); createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like); createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike); } if (parentFolder != null && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, 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); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DELETE); } }
From source file:com.acrylicgoat.scrumnotes.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from www .j a v a2 s .co m getMenuInflater().inflate(R.menu.activity_main, menu); readDB(); if (devs != null && devs.size() > 0) { for (int i = 0; i < devs.size(); i++) { Developer dev = (Developer) devs.get(i); menu.add(0, MENUITEM, 0, dev.getName()); } } boolean drawerOpen = drawerLayout.isDrawerOpen(drawerList); menu.findItem(R.id.save).setVisible(!drawerOpen); return true; }
From source file:com.gh4a.activities.DiffViewerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.download_menu, menu); menu.removeItem(R.id.download);//w w w . j a va 2s. c o m String viewAtTitle = getString(R.string.object_view_file_at, mSha.substring(0, 7)); MenuItem item = menu.add(0, MENU_ITEM_VIEW, Menu.NONE, viewAtTitle); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_NEVER); return super.onCreateOptionsMenu(menu); }
From source file:com.appunite.appunitevideoplayer.PlayerActivity.java
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener, final int trackType) { if (player == null) { return;// w w w . ja va 2s . co m } int trackCount = player.getTrackCount(trackType); if (trackCount == 0) { return; } popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item)) || onTrackItemClick(item, trackType); } }); Menu menu = popup.getMenu(); // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0) menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off); for (int i = 0; i < trackCount; i++) { menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i))); } menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true); menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true); }
From source file:com.chaturs.notepad.NoteEditor.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Build the menus that are shown when editing. if (mState == STATE_EDIT) { menu.add(0, REVERT_ID, 0, R.string.menu_revert).setShortcut('0', 'r') .setIcon(android.R.drawable.ic_menu_revert); if (!mNoteOnly) { menu.add(0, DELETE_ID, 0, R.string.menu_delete).setShortcut('1', 'd') .setIcon(android.R.drawable.ic_menu_delete); menu.add(0, SAVE_ID, 0, "Save").setIcon(android.R.drawable.ic_menu_save); menu.add(0, POST_ID, 0, "Post").setIcon(android.R.drawable.ic_menu_report_image); }/*from w w w . j a v a 2 s .co m*/ // Build the menus that are shown when inserting. } else { menu.add(0, DISCARD_ID, 0, R.string.menu_discard).setShortcut('0', 'd') .setIcon(android.R.drawable.ic_menu_delete); menu.add(0, SAVE_ID, 0, "Save").setIcon(android.R.drawable.ic_menu_save); } menu.add(0, LIST_ID, 0, "Notes").setIcon(R.drawable.ic_menu_annotatelist); if (!mNoteOnly) { Intent intent = new Intent(null, getIntent().getData()); } return true; }
From source file:com.fbbackup.MyFriendFragmentActivity.java
@Override public boolean onCreatePanelMenu(int featureId, Menu menu) { // TODO Auto-generated method stub //1:sid, 2:itemId, 3:item, 4:itemW menu.add(0, 0, 0, getString(R.string.menu_info)); menu.add(0, 1, 1, getString(R.string.menu_about)); return super.onCreatePanelMenu(featureId, menu); }
From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetDrive.java
@Override public final boolean onCreateOptionsMenu(final Menu menu) { menu.add(0, R.string.get_maplocation, 0, R.string.get_maplocation) .setIcon(android.R.drawable.ic_menu_mylocation).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, R.string.deljustbefore, 0, R.string.deljustbefore).setIcon(android.R.drawable.ic_menu_delete) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, R.string.settings, 0, R.string.settings).setIcon(android.R.drawable.ic_menu_preferences); menu.add(0, R.string.copyright, 0, R.string.copyright).setIcon(android.R.drawable.ic_menu_info_details); menu.add(0, R.string.back, 0, R.string.back).setIcon(android.R.drawable.ic_menu_close_clear_cancel); return true;/*w ww .ja v a 2 s. c o m*/ }
From source file:org.alfresco.mobile.android.application.fragments.menu.MainMenuFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();//from w w w .j ava 2 s . com if (showOperationsMenu) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_notifications, Menu.FIRST, R.string.notifications); mi.setIcon(R.drawable.ic_events_dark); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:fm.smart.r1.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); menu.add(0, ADD_TO_GOAL_ID, 0, R.string.menu_add_to_goal).setIcon(android.R.drawable.ic_menu_add); return true;//from w ww . j a v a2s .com }