List of usage examples for android.view ContextMenu addSubMenu
SubMenu addSubMenu(final CharSequence title);
From source file:com.audiokernel.euphonyrmt.fragments.BrowseFragment.java
@Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenu.ContextMenuInfo menuInfo) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; final int index = (int) info.id; if (index >= 0 && mItems.size() > index) { menu.setHeaderTitle(mItems.get((int) info.id).toString()); // If in simple mode, show "Play" (add, replace & play), "Add to queue" and "Add to playlist" if (mApp.isInSimpleMode()) { final MenuItem playItem = menu.add(ADD_REPLACE_PLAY, ADD_REPLACE_PLAY, 0, R.string.play); playItem.setOnMenuItemClickListener(this); final MenuItem addItem = menu.add(ADD, ADD, 0, R.string.addToQueue); addItem.setOnMenuItemClickListener(this); } else {// w w w .j a va2 s . c o m final MenuItem addItem = menu.add(ADD, ADD, 0, mIrAdd); addItem.setOnMenuItemClickListener(this); final MenuItem addAndReplaceItem = menu.add(ADD_REPLACE, ADD_REPLACE, 0, R.string.addAndReplace); addAndReplaceItem.setOnMenuItemClickListener(this); final MenuItem addAndReplacePlayItem = menu.add(ADD_REPLACE_PLAY, ADD_REPLACE_PLAY, 0, R.string.addAndReplacePlay); addAndReplacePlayItem.setOnMenuItemClickListener(this); final MenuItem addAndPlayItem = menu.add(ADD_PLAY, ADD_PLAY, 0, R.string.addAndPlay); addAndPlayItem.setOnMenuItemClickListener(this); } if (R.string.addPlaylist != mIrAdd && R.string.addStream != mIrAdd && mApp.oMPDAsyncHelper.oMPD.isCommandAvailable(MPDCommand.MPD_CMD_LISTPLAYLISTS)) { int id = 0; final SubMenu playlistMenu = menu.addSubMenu(R.string.addToPlaylist); MenuItem item = playlistMenu.add(ADD_TO_PLAYLIST, id++, (int) info.id, R.string.newPlaylist); item.setOnMenuItemClickListener(this); try { final List<Item> playlists = mApp.oMPDAsyncHelper.oMPD.getPlaylists(); if (null != playlists) { for (final Item pl : playlists) { item = playlistMenu.add(ADD_TO_PLAYLIST, id++, (int) info.id, pl.getName()); item.setOnMenuItemClickListener(this); } } } catch (final IOException | MPDException e) { Log.e(TAG, "Failed to parse playlists.", e); } } final MenuItem gotoArtistItem = menu.add(GOTO_ARTIST, GOTO_ARTIST, 0, R.string.goToArtist); gotoArtistItem.setOnMenuItemClickListener(this); } }