Example usage for android.view ContextMenu add

List of usage examples for android.view ContextMenu add

Introduction

In this page you can find the example usage for android.view ContextMenu add.

Prototype

public MenuItem add(int groupId, int itemId, int order, CharSequence title);

Source Link

Document

Add a new item to the menu.

Usage

From source file:com.andrew.apollo.ui.fragments.PlaylistFragment.java

/**
 * {@inheritDoc}/*from  ww  w  .j  av  a 2 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;
    final int mPosition = info.position;
    // Create a new playlist
    mPlaylist = mAdapter.getItem(mPosition);

    // Play the playlist
    menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, R.string.context_menu_play_selection);

    // Add the playlist to the queue
    menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, R.string.add_to_queue);

    // Delete and rename (user made playlists)
    if (info.position > 1) {
        menu.add(GROUP_ID, FragmentMenuItems.RENAME_PLAYLIST, Menu.NONE, R.string.context_menu_rename_playlist);

        menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, R.string.context_menu_delete);

    }
}

From source file:com.normalexception.app.rx8club.fragment.category.CategoryFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(Menu.NONE, MENU_FAVE, Menu.NONE, "Add As Favorite");
    menu.add(Menu.NONE, MENU_FILTER_USER, Menu.NONE, "Add As User Filter");
    menu.add(Menu.NONE, MENU_FILTER_TITLE, Menu.NONE, "Add As Title Filter");
    menu.add(Menu.NONE, MENU_FILTER_LASTUSER, Menu.NONE, "Add As Last User Filter");
}

From source file:com.sandklef.coachapp.fragments.TrainingPhasesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    Log.d(LOG_TAG, "  onCreateContextMenu()");

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    String word = ((TextView) info.targetView).getText().toString();
    long id = info.id;

    menu.setHeaderTitle("Select");
    try {/*from  ww  w. ja v  a2s  . co  m*/
        currentTPId = Storage.getInstance().getTrainingPhases().get((int) id).getUuid();
        menu.add(0, v.getId(), 0, "Create instruction video");
    } catch (StorageNoClubException e) {
        e.printStackTrace();
    }

}

From source file:com.nttec.everychan.ui.HistoryFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (adapter == null)
        return;//from www .j  a v  a 2 s .  c om
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Object item = adapter.getItem(info.position);
    if (item instanceof Database.HistoryEntry) {
        Database.HistoryEntry entry = (Database.HistoryEntry) item;
        if (entry.date != 0) {
            menu.add(Menu.NONE, R.id.context_menu_remove_history, 1, R.string.context_menu_remove_history);
            menu.add(Menu.NONE, R.id.context_menu_open_browser, 2, R.string.context_menu_open_browser);
            menu.add(Menu.NONE, R.id.context_menu_favorites_from_fragment, 3,
                    MainApplication.getInstance().database.isFavorite(entry.chan, entry.board, entry.boardPage,
                            entry.thread) ? R.string.context_menu_remove_favorites
                                    : R.string.context_menu_add_favorites);
        }
    }
}

From source file:com.cl.slack.gesture.GestureBuilderActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(((TextView) info.targetView).getText());

    menu.add(0, MENU_ID_RENAME, 0, R.string.gestures_rename);
    menu.add(0, MENU_ID_REMOVE, 0, R.string.gestures_delete);
}

From source file:com.android.music.PlaylistBrowserFragment.java

public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    if (mCreateShortcut) {
        return;/*  www  . j av  a 2  s.  co  m*/
    }

    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfoIn;

    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);

    if (mi.id >= 0 /*|| mi.id == PODCASTS_PLAYLIST*/) {
        menu.add(0, DELETE_PLAYLIST, 0, R.string.delete_playlist_menu);
    }

    if (mi.id == RECENTLY_ADDED_PLAYLIST) {
        menu.add(0, EDIT_PLAYLIST, 0, R.string.edit_playlist_menu);
    }

    if (mi.id >= 0) {
        menu.add(0, RENAME_PLAYLIST, 0, R.string.rename_playlist_menu);
    }

    mPlaylistCursor.moveToPosition(mi.position);
    menu.setHeaderTitle(
            mPlaylistCursor.getString(mPlaylistCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.NAME)));
}

From source file:com.asksven.commandcenter.BasicMasterFragment.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, v, info);
    menu.setHeaderTitle("Actions");
    // menu depends on capabilities
    if (m_bEditable) {
        menu.add(m_iContextMenuId, CONTEXT_ADD_ID, Menu.NONE, "Add");
        menu.add(m_iContextMenuId, CONTEXT_EDIT_ID, Menu.NONE, "Edit");
        menu.add(m_iContextMenuId, CONTEXT_DELETE_ID, Menu.NONE, "Delete");
        menu.add(m_iContextMenuId, CONTEXT_EXECUTE_ID, Menu.NONE, "Execute");

    } else {//  www  .  j  a va 2 s . co m
        menu.add(m_iContextMenuId, CONTEXT_VIEW_ID, Menu.NONE, "View");
        menu.add(m_iContextMenuId, CONTEXT_EXECUTE_ID, Menu.NONE, "Execute");
        menu.add(m_iContextMenuId, CONTEXT_ADDUSER_ID, Menu.NONE, "Copy to User");
        //           menu.add(m_iContextMenuId, CONTEXT_REFRESH, Menu.NONE, "Refresh");
        //           menu.add(m_iContextMenuId, CONTEXT_RELOAD, Menu.NONE, "Reload");
    }
}

From source file:com.normalexception.app.rx8club.fragment.pm.PrivateMessageInboxFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    int position = info.position;
    PMModel pmv = (PMModel) lv.getItemAtPosition(position);
    menu.setHeaderTitle(pmv.getTitle());
    if (!this.showOutbound)
        menu.add(0, position, 0, R.string.reply);
    menu.add(0, position, 0, R.string.delete);
}

From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    menu.add(MENU_ITEM_ADD, MENU_ITEM_ADD, 1, R.string.list_menu_add);
    menu.add(MENU_ITEM_DELETE, MENU_ITEM_DELETE, 2, R.string.list_meanu_delete);
}