예제 #1
0
  /** {@inheritDoc} */
  @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));
  }
  /** {@inheritDoc} */
  @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 - 1;
    // 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, false);

    // 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));
  }
 // submenu dos itens da aplicacao
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   menu.addSubMenu(Menu.NONE, 0, Menu.NONE, R.string.submenu_call);
   menu.addSubMenu(Menu.NONE, 1, Menu.NONE, R.string.submenu_sms);
   menu.addSubMenu(Menu.NONE, 2, Menu.NONE, R.string.submenu_find_map);
   menu.addSubMenu(Menu.NONE, 3, Menu.NONE, R.string.submenu_website);
   menu.addSubMenu(Menu.NONE, 4, Menu.NONE, R.string.submenu_remove);
   menu.addSubMenu(Menu.NONE, 5, Menu.NONE, R.string.submenu_send_email);
   menu.addSubMenu(Menu.NONE, 6, Menu.NONE, R.string.submenu_share);
   super.onCreateContextMenu(menu, v, menuInfo);
 }