/** * Zeigt das Menu in Abhaengigkeit der Action. * * <p>Ist die Action == EDIT, wird im Item R.id.menu_item_create_RegelmBuchung_fromUmsatz die ID * des Umsatzes unter ID in einem Intent gespeichert. * * <p>Ist die Action == EDIT und ist es eine Umbuchung, wird unter R.id.menu_item_toUmbuchung die * ID der Gegenbuchung unter ID in einem Intent gespeichert. */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); Intent intent = new Intent(); inflater.inflate(R.menu.fragment_buchungen, menu); switch (getMainAction()) { case ADD: menu.findItem(R.id.menu_item_delete_Buchung).setVisible(false); menu.findItem(R.id.menu_item_toUmbuchung).setVisible(false); menu.findItem(R.id.menu_item_create_RegelmBuchung_fromUmsatz).setVisible(false); break; case EDIT: MenuItem item; if (mUmsatz.isInserted()) { intent.putExtra(ID, mUmsatz.getID()); item = menu.findItem(R.id.menu_item_create_RegelmBuchung_fromUmsatz); item.setIntent(intent); } item = menu.findItem(R.id.menu_item_toUmbuchung); if (mUmsatz.isUmbuchung()) { menu.findItem(R.id.menu_item_delete_Buchung).setVisible(false); menu.findItem(R.id.menu_item_SplitBuchung).setVisible(false); intent.putExtra(ID, mUmsatz.getAsLong(R.string.column_transferID)); item.setIntent(intent); } else { item.setVisible(false); } break; } }
@Override public void buildContextMenu(ContextMenu menu, XbmcRequester requester) { // intent.putExtra("FOLDER", getFilePath()); // // intent.putExtra("MEDIA_TYPE", getPlaylistId()); // // intent.putExtra("TYPE", getType()); // MenuItem playItem = menu.add(R.string.play); Intent intent = new Intent(); intent.putExtra("WHERECLAUSE", "idEpisode = " + idEpisode); intent.putExtra("EXEC_MODE", execModeEnum.Play); playItem.setIntent(intent); playItem.setOnMenuItemClickListener(new playVideoSelectionMenuItemClickListener()); // playItem = menu.add(R.string.enqueue); Intent intent2 = new Intent(); intent2.putExtra("EXEC_MODE", execModeEnum.Enqueue); intent2.putExtra("WHERECLAUSE", "idEpisode = " + idEpisode); playItem.setIntent(intent2); playItem.setOnMenuItemClickListener(new playVideoSelectionMenuItemClickListener()); playItem = menu.add(R.string.clear_playlist); playItem.setOnMenuItemClickListener(new ClearPlaylistMenuItemClickListener()); }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // don't offer menus when creating shortcut if (makingShortcut) return true; // add host, ssh keys, about sortcolor = menu.add(R.string.list_menu_sortcolor); sortcolor.setIcon(android.R.drawable.ic_menu_share); sortcolor.setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { sortedByColor = true; updateList(); return true; } }); sortlast = menu.add(R.string.list_menu_sortname); sortlast.setIcon(android.R.drawable.ic_menu_share); sortlast.setOnMenuItemClickListener( new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { sortedByColor = false; updateList(); return true; } }); MenuItem keys = menu.add(R.string.list_menu_pubkeys); keys.setIcon(android.R.drawable.ic_lock_lock); keys.setIntent(new Intent(HostListActivity.this, PubkeyListActivity.class)); MenuItem colors = menu.add("Colors"); colors.setIcon(android.R.drawable.ic_menu_slideshow); colors.setIntent(new Intent(HostListActivity.this, ColorsActivity.class)); MenuItem settings = menu.add(R.string.list_menu_settings); settings.setIcon(android.R.drawable.ic_menu_preferences); settings.setIntent(new Intent(HostListActivity.this, SettingsActivity.class)); MenuItem help = menu.add(R.string.title_help); help.setIcon(android.R.drawable.ic_menu_help); help.setIntent(new Intent(HostListActivity.this, HelpActivity.class)); return true; }
/** * Prepares the help menu item by doing the following. - If the helpUrlString is empty or null, * the help menu item is made invisible. - Otherwise, this makes the help menu item visible and * sets the intent for the help menu item to view the URL. * * @return returns whether the help menu item has been made visible. */ public static boolean prepareHelpMenuItem( Context context, MenuItem helpMenuItem, String helpUrlString) { if (TextUtils.isEmpty(helpUrlString)) { // The help url string is empty or null, so set the help menu item to be invisible. helpMenuItem.setVisible(false); // return that the help menu item is not visible (i.e. false) return false; } else { // The help url string exists, so first add in some extra query parameters. final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString)); // Then, create an intent that will be fired when the user // selects this help menu item. Intent intent = new Intent(Intent.ACTION_VIEW, fullUri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // Set the intent to the help menu item, show the help menu item in the overflow // menu, and make it visible. ComponentName component = intent.resolveActivity(context.getPackageManager()); if (component != null) { helpMenuItem.setIntent(intent); helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); helpMenuItem.setVisible(true); } else { helpMenuItem.setVisible(false); return false; } // return that the help menu item is visible (i.e., true) return true; } }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // book이 지정되어있지 않으면 신규 추가는 불가능 하도록 한다. if (mBook >= 0) { menu.add(0, MENU_ITEM_ADDNOTE, 0, R.string.menu_addnote) .setIcon(android.R.drawable.ic_menu_add); } menu.add(0, MENU_ITEM_ALLLIST, 0, R.string.menu_allnote) .setIcon(android.R.drawable.ic_menu_agenda); menu.add(0, MENU_ITEM_BOOKLIST, 0, R.string.menu_booksnote) .setIcon(android.R.drawable.ic_menu_agenda); menu.add(0, MENU_ITEM_DAYSLIST, 0, R.string.menu_daysnote) .setIcon(android.R.drawable.ic_menu_agenda); MenuItem item1 = menu.add(0, MENU_ITEM_BIBLEVIEW, 0, R.string.menu_bibleview); item1.setIntent(new Intent(getBaseContext(), BibleViewer.class)); item1.setIcon(R.drawable.app_notes); /* MenuItem item2 = menu.add(0, MENU_ITEM_EDITNOTE, 0, R.string.menu_editnote); item2.setIntent(new Intent(getBaseContext(), NoteEditor.class)); item2.setIcon(android.R.drawable.ic_menu_edit); MenuItem item3 = menu.add(0, MENU_ITEM_DELNOTE, 0, R.string.menu_deletenote); item3.setIntent(new Intent(getBaseContext(), NoteEditor.class)); item3.setIcon(android.R.drawable.ic_menu_delete); */ return true; }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem menuItem = menu.add(mSettingsTitle); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menuItem.setIntent(mSettingsIntent); }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); // prefs intent Intent prefsIntent = new Intent(this.getApplicationContext(), PrefsActivity.class); MenuItem preferences = menu.findItem(R.id.settings_option_item); preferences.setIntent(prefsIntent); // import/export intent Intent importExportIntent = new Intent(this.getApplicationContext(), ImportExportActivity.class); MenuItem importexport = menu.findItem(R.id.importexport_option_item); importexport.setIntent(importExportIntent); return true; }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mHelpUrl != null) { Intent helpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mHelpUrl)); helpIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); MenuItem helpItem = menu.add(0, MENU_HELP, 0, R.string.help_label); helpItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); helpItem.setIntent(helpIntent); } }
public void addHelpMenuItem(Menu menu, String activityName, boolean showAsAction) { Intent helpIntent = getHelpIntent(activityName); if (helpIntent != null) { MenuInflater inflater = new MenuInflater(mContext); inflater.inflate(R.menu.help, menu); MenuItem item = menu.findItem(R.id.menu_help); item.setIntent(helpIntent); if (showAsAction) { item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } } }
@Override public void onClick(View view) { final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view); final Menu menu = popupMenu.getMenu(); popupMenu.inflate(R.menu.dialtacts_search_options); final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option); filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener); final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact); addContactOptionMenuItem.setIntent( new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); popupMenu.show(); }
// Show a little menu, with a link to hiveminder.com/todo public boolean onCreateOptionsMenu(Menu menu) { Intent hmlistIntent = new Intent("org.nerdcircus.android.hiveminder.SEARCH"); hmlistIntent.putExtra(SearchManager.QUERY, ""); // XXX: trick, to get a null search. menu.add("Show ToDo List").setIntent(hmlistIntent); MenuItem mi = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Preferences"); mi.setIcon(android.R.drawable.ic_menu_preferences); Intent i = new Intent(Intent.ACTION_MAIN); i.setClassName(this, "org.nerdcircus.android.hiveminder.Preferences"); mi.setIntent(i); return true; }
@Override protected boolean onCreateActionBar(Menu menu) { Activity activity = mActivity; final boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); MenuInflater inflater = getSupportMenuInflater(); if (mGetContent) { inflater.inflate(R.menu.pickup, menu); int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE); mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); } else if (mGetAlbum) { inflater.inflate(R.menu.pickup, menu); mActionBar.setTitle(R.string.select_album); } else { inflater.inflate(R.menu.albumset, menu); boolean wasShowingClusterMenu = mShowClusterMenu; mShowClusterMenu = !inAlbum; if (mShowClusterMenu != wasShowingClusterMenu) { if (mShowClusterMenu) { mActionBar.enableClusterMenu(mSelectedAction, this); } else { mActionBar.disableClusterMenu(true); } } boolean selectAlbums = !inAlbum && mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM; MenuItem selectItem = menu.findItem(R.id.action_select); selectItem.setTitle( activity.getString(selectAlbums ? R.string.select_album : R.string.select_group)); MenuItem cameraItem = menu.findItem(R.id.action_camera); cameraItem.setVisible(GalleryUtils.isCameraAvailable(activity)); FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false); Intent helpIntent = HelpUtils.getHelpIntent(activity); MenuItem helpItem = menu.findItem(R.id.action_general_help); helpItem.setVisible(helpIntent != null); if (helpIntent != null) helpItem.setIntent(helpIntent); MenuItem moreItem = menu.findItem(R.id.action_more_image); moreItem.setVisible(mActivity.getResources().getBoolean(R.bool.config_show_more_images)); mActionBar.setTitle(mTitle); mActionBar.setSubtitle(mSubtitle); } return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); // Cargamos el menú desde el fichero de recursos indicado por su identificador en la variable R MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.main_menu, menu); // Capturamos el item "Ayuda" del menú, para asociarle una intención, // en este caso la itención que está asociada a la actividad HelpActivity MenuItem newMenuItem = menu.findItem(R.id.miNuevo); newMenuItem.setIntent(new Intent("com.pernix.contactos.intent.action.NEW")); return result; }
public static void prepareHelpMenuItem(Context context, MenuItem helpMenuItem) { String helpUrlString = context.getResources().getString(R.string.desk_clock_help_url); if (TextUtils.isEmpty(helpUrlString)) { // The help url string is empty or null, so set the help menu item to be invisible. helpMenuItem.setVisible(false); return; } // The help url string exists, so first add in some extra query parameters. 87 final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString)); // Then, create an intent that will be fired when the user // selects this help menu item. Intent intent = new Intent(Intent.ACTION_VIEW, fullUri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // Set the intent to the help menu item, show the help menu item in the overflow // menu, and make it visible. helpMenuItem.setIntent(intent); helpMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); helpMenuItem.setVisible(true); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo; Task task = ((ViewHolder) adapterInfo.targetView.getTag()).task; if (task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY)) return; int id = (int) task.getId(); menu.setHeaderTitle(task.getValue(Task.TITLE)); if (task.isDeleted()) { menu.add(id, CONTEXT_MENU_UNDELETE_TASK_ID, Menu.NONE, R.string.TAd_contextUndeleteTask); menu.add(id, CONTEXT_MENU_PURGE_TASK_ID, Menu.NONE, R.string.TAd_contextPurgeTask); } else { menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE, R.string.TAd_contextEditTask); menu.add(id, CONTEXT_MENU_COPY_TASK_ID, Menu.NONE, R.string.TAd_contextCopyTask); for (int i = 0; i < contextItemExposers.length; i++) { Object label = contextItemExposers[i].getLabel(task); if (label != null) { if (label instanceof Integer) menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (Integer) label); else menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (String) label); } } long taskId = task.getId(); for (ContextMenuItem item : contextMenuExtensionLoader.getList()) { android.view.MenuItem menuItem = menu.add(id, CONTEXT_MENU_BROADCAST_INTENT_ID, Menu.NONE, item.title); item.intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId); menuItem.setIntent(item.intent); } menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE, R.string.TAd_contextDeleteTask); } }
public boolean bindNativeOverflow( android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap<android.view.MenuItem, MenuItemImpl> map) { final List<MenuItemImpl> nonActionItems = getNonActionItems(); if (nonActionItems == null || nonActionItems.size() == 0) { return false; } boolean visible = false; menu.clear(); for (MenuItemImpl nonActionItem : nonActionItems) { if (!nonActionItem.isVisible()) { continue; } visible = true; android.view.MenuItem nativeItem; if (nonActionItem.hasSubMenu()) { android.view.SubMenu nativeSub = menu.addSubMenu( nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); SubMenuBuilder subMenu = (SubMenuBuilder) nonActionItem.getSubMenu(); for (MenuItemImpl subItem : subMenu.getVisibleItems()) { android.view.MenuItem nativeSubItem = nativeSub.add( subItem.getGroupId(), subItem.getItemId(), subItem.getOrder(), subItem.getTitle()); nativeSubItem.setIcon(subItem.getIcon()); nativeSubItem.setOnMenuItemClickListener(listener); nativeSubItem.setEnabled(subItem.isEnabled()); nativeSubItem.setIntent(subItem.getIntent()); nativeSubItem.setNumericShortcut(subItem.getNumericShortcut()); nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut()); nativeSubItem.setTitleCondensed(subItem.getTitleCondensed()); nativeSubItem.setCheckable(subItem.isCheckable()); nativeSubItem.setChecked(subItem.isChecked()); if (subItem.isExclusiveCheckable()) { nativeSub.setGroupCheckable(subItem.getGroupId(), true, true); } map.put(nativeSubItem, subItem); } nativeItem = nativeSub.getItem(); } else { nativeItem = menu.add( nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); } nativeItem.setIcon(nonActionItem.getIcon()); nativeItem.setOnMenuItemClickListener(listener); nativeItem.setEnabled(nonActionItem.isEnabled()); nativeItem.setIntent(nonActionItem.getIntent()); nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut()); nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut()); nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed()); nativeItem.setCheckable(nonActionItem.isCheckable()); nativeItem.setChecked(nonActionItem.isChecked()); if (nonActionItem.isExclusiveCheckable()) { menu.setGroupCheckable(nonActionItem.getGroupId(), true, true); } map.put(nativeItem, nonActionItem); } return visible; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar); final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option); final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact); final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings); final MenuItem fakeMenuItem = menu.findItem(R.id.fake_menu_item); Tab tab = getActionBar().getSelectedTab(); if (mInSearchUi) { searchMenuItem.setVisible(false); if (ViewConfiguration.get(this).hasPermanentMenuKey()) { filterOptionMenuItem.setVisible(true); filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener); addContactOptionMenuItem.setVisible(true); addContactOptionMenuItem.setIntent(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); } else { // Filter option menu should be not be shown as a overflow menu. filterOptionMenuItem.setVisible(false); addContactOptionMenuItem.setVisible(false); } callSettingsMenuItem.setVisible(false); fakeMenuItem.setVisible(false); } else { final boolean showCallSettingsMenu; if (tab != null && tab.getPosition() == TAB_INDEX_DIALER) { if (DEBUG) { Log.d( TAG, "onPrepareOptionsMenu(dialer). swipe: " + mDuringSwipe + ", user tab click: " + mUserTabClick); } if (mDuringSwipe || mUserTabClick) { // During horizontal movement, we just show real ActionBar menu items. searchMenuItem.setVisible(true); searchMenuItem.setOnMenuItemClickListener(mSearchMenuItemClickListener); showCallSettingsMenu = true; fakeMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); } else { searchMenuItem.setVisible(false); // When permanent menu key is _not_ available, the call settings menu should be // available via DialpadFragment. showCallSettingsMenu = ViewConfiguration.get(this).hasPermanentMenuKey(); fakeMenuItem.setVisible(false); } } else { searchMenuItem.setVisible(true); searchMenuItem.setOnMenuItemClickListener(mSearchMenuItemClickListener); showCallSettingsMenu = true; fakeMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); } if (tab != null && tab.getPosition() == TAB_INDEX_FAVORITES) { filterOptionMenuItem.setVisible(true); filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener); addContactOptionMenuItem.setVisible(true); addContactOptionMenuItem.setIntent(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); } else { filterOptionMenuItem.setVisible(false); addContactOptionMenuItem.setVisible(false); } if (showCallSettingsMenu) { callSettingsMenuItem.setVisible(true); callSettingsMenuItem.setIntent(DialtactsActivity.getCallSettingsIntent()); } else { callSettingsMenuItem.setVisible(false); } } return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem menuItem = menu.add(0, MENU_ABOUT, 0, getString(R.string.about)); menuItem.setIntent(new Intent(this, activityAbout.class)); return true; }
public boolean onCreateOptionsMenu(Menu menu) { MenuItem mi = menu.add(0, 1, 0, "Prefs"); mi.setIntent(new Intent(this, PrefAct.class)); return super.onCreateOptionsMenu(menu); }
@Override public MenuItem setIntent(Intent intent) { mNativeItem.setIntent(intent); return this; }