List of usage examples for android.view ContextMenu add
public MenuItem add(int groupId, int itemId, int order, CharSequence title);
From source file:com.andrew.apollo.ui.fragments.LastAddedFragment.java
/** * {@inheritDoc}//from w w w. j a v a 2 s.c om */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; mSelectedPosition = info.position; // Creat a new song mSong = mAdapter.getItem(mSelectedPosition); mSelectedId = mSong.mSongId; mSongName = mSong.mSongName; mAlbumName = mSong.mAlbumName; mArtistName = mSong.mArtistName; // Play the song menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Play next menu.add(GROUP_ID, FragmentMenuItems.PLAY_NEXT, Menu.NONE, getString(R.string.context_menu_play_next)); // Add the song to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the song to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, true); // View more content by the song artist menu.add(GROUP_ID, FragmentMenuItems.MORE_BY_ARTIST, Menu.NONE, getString(R.string.context_menu_more_by_artist)); // Make the song a ringtone menu.add(GROUP_ID, FragmentMenuItems.USE_AS_RINGTONE, Menu.NONE, getString(R.string.context_menu_use_as_ringtone)); // Delete the song menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }
From source file:org.linphone.ChatFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == R.id.sendPicture) { menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small)); menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium)); menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large)); // Not a good idea, very big pictures cause Out of Memory exceptions, slow display, ... // menu.add(0, MENU_PICTURE_REAL, 0, getString(R.string.share_picture_size_real)); } else {/*from ww w . java 2 s.c o m*/ menu.add(v.getId(), MENU_DELETE_MESSAGE, 0, getString(R.string.delete)); menu.add(v.getId(), MENU_COPY_TEXT, 0, getString(R.string.copy_text)); } LinphoneChatMessage msg = getMessageForId(v.getId()); if (msg != null && msg.getStatus() == LinphoneChatMessage.State.NotDelivered) { menu.add(v.getId(), MENU_RESEND_MESSAGE, 0, getString(R.string.retry)); } }
From source file:org.mklab.mikity.android.SceneGraphTreeFragment.java
/** * {@inheritDoc}/*from w w w.java 2s . com*/ */ @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (view.getId() == R.id.scene_graph_tree_view) { menu.add(0, CONTEXT_MENU_CUT, 0, R.string.cut); menu.add(0, CONTEXT_MENU_COPY, 0, R.string.copy); menu.add(0, CONTEXT_MENU_PASTE, 0, R.string.paste); menu.add(0, CONTEXT_MENU_DELETE, 0, R.string.delete); menu.add(0, CONTEXT_MENU_EDIT, 0, R.string.edit); //menu.add(0, CONTEXT_MENU_TRANSFORM, 0, R.string.transform); } }
From source file:com.andrew.apollo.ui.fragments.SongFragment.java
/** * {@inheritDoc}/*from w w w . j av a 2 s . c om*/ */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; mSelectedPosition = info.position; // Creat a new song mSong = mAdapter.getItem(mSelectedPosition); mSelectedId = Long.valueOf(mSong.mSongId); mSongName = mSong.mSongName; mAlbumName = mSong.mAlbumName; mArtistName = mSong.mArtistName; // Play the song menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Add the song to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the song to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getSherlockActivity(), GROUP_ID, subMenu, true); // View more content by the song artist menu.add(GROUP_ID, FragmentMenuItems.MORE_BY_ARTIST, Menu.NONE, getString(R.string.context_menu_more_by_artist)); // Make the song a ringtone menu.add(GROUP_ID, FragmentMenuItems.USE_AS_RINGTONE, Menu.NONE, getString(R.string.context_menu_use_as_ringtone)); // Delete the song menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }
From source file:com.jefftharris.passwdsafe.PasswdSafeListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; PasswdRecordListData listItem = itsAdapter.getItem(info.position); if (listItem.itsIsRecord) { menu.setHeaderTitle(listItem.itsTitle); int group = itsIsContents ? PasswdSafe.CONTEXT_GROUP_LIST_CONTENTS : PasswdSafe.CONTEXT_GROUP_LIST; menu.add(group, R.id.menu_copy_user, 0, R.string.copy_user); menu.add(group, R.id.menu_copy_password, 0, R.string.copy_password); }/*from ww w . ja v a2s . co m*/ }
From source file:com.boko.vimusic.ui.fragments.ArtistFragment.java
/** * {@inheritDoc}/* ww w.j a v a 2 s . co m*/ */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; // Creat a new model mArtist = mAdapter.getItem(info.position); // Create a list of the artist's songs mArtistList = MusicUtils.getSongListForArtist(getActivity(), mArtist.getId()); // Play the artist menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Add the artist to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the artist to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false); // Delete the artist menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }
From source file:com.guayaba.tapir.ui.fragments.ArtistFragment.java
/** * {@inheritDoc}/*from w w w . j a v a2 s . c o m*/ */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; // Creat a new model mArtist = mAdapter.getItem(info.position); // Create a list of the artist's songs mArtistList = MusicUtils.getSongListForArtist(getActivity(), mArtist.mArtistId); // Play the artist menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Add the artist to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the artist to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false); // Delete the artist menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }
From source file:com.guayaba.tapir.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}/*from w w w .j av a 2 s. c om*/ */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; // Create a new album mAlbum = mAdapter.getItem(info.position); // Create a list of the album's songs mAlbumList = MusicUtils.getSongListForAlbum(getActivity(), mAlbum.mAlbumId); // Play the album menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Add the album to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the album to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false); // View more content by the album artist menu.add(GROUP_ID, FragmentMenuItems.MORE_BY_ARTIST, Menu.NONE, getString(R.string.context_menu_more_by_artist)); // Remove the album from the list menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }
From source file:org.opendatakit.tables.activities.TableManager.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo; TableProperties tp = tableProps[acmi.position]; if (tp.getTableId().equals(prefs.getDefaultTableId())) { menu.add(0, UNSET_DEFAULT_TABLE, 0, getString(R.string.unset_as_default_table)); } else {//from w w w. j a va 2 s. c om menu.add(0, SET_DEFAULT_TABLE, 0, getString(R.string.set_as_default_table)); } TableType tableType = tp.getTableType(); if (tableType == TableType.data) { if (couldBeSecurityTable(tp)) { menu.add(0, SET_SECURITY_TABLE, 0, getString(R.string.set_as_access_control_table)); } if (couldBeShortcutTable(tp)) { menu.add(0, SET_SHORTCUT_TABLE, 0, getString(R.string.set_as_shortcut_table)); } } else if (tableType == TableType.security) { menu.add(0, UNSET_SECURITY_TABLE, 0, getString(R.string.unset_as_access_control_table)); } else if (tableType == TableType.shortcut) { menu.add(0, UNSET_SHORTCUT_TABLE, 0, getString(R.string.unset_as_shortcut_table)); } menu.add(0, REMOVE_TABLE, 1, getString(R.string.delete_table)); menu.add(0, LAUNCH_TPM, 2, getString(R.string.edit_table_props)); menu.add(0, LAUNCH_CONFLICT_MANAGER, 3, getString(R.string.manage_conflicts)); menu.add(0, LAUNCH_SECURITY_MANAGER, 4, getString(R.string.security_manager)); }
From source file:com.boko.vimusic.ui.fragments.AlbumFragment.java
/** * {@inheritDoc}//from w ww . ja va2 s . c om */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the position of the selected item final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; // Create a new album mAlbum = mAdapter.getItem(info.position); // Create a list of the album's songs mAlbumList = MusicUtils.getSongListForAlbum(getActivity(), mAlbum.getId()); // Play the album menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)); // Add the album to the queue menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)); // Add the album to a playlist final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist); MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, false); // View more content by the album artist menu.add(GROUP_ID, FragmentMenuItems.MORE_BY_ARTIST, Menu.NONE, getString(R.string.context_menu_more_by_artist)); // Remove the album from the list menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)); }