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:org.yaoha.YaohaActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Action");
    menu.add(0, v.getId(), 0, EDIT_FAV_STRING);
    menu.add(0, v.getId(), 0, EDIT_FAV_PIC);
    menu.add(0, v.getId(), 0, REMOVE_FAV);
}

From source file:com.meetingninja.csse.meetings.MeetingsFragment.java

private void setupSwipeList() {
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/*  w w w  . ja v a  2 s .c o m*/
        public void onItemClick(AdapterView<?> parentAdapter, View v, int position, long id) {
            Meeting clicked = meetingAdpt.getItem(position);
            loadMeeting(clicked);
        }
    });

    mListView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;

            Meeting longClicked = meetingAdpt.getItem(aInfo.position);

            menu.setHeaderTitle("Options for " + longClicked.getTitle());
            menu.add(MainActivity.DrawerLabel.MEETINGS.getPosition(), aInfo.position, 1, "Edit");
            menu.add(MainActivity.DrawerLabel.MEETINGS.getPosition(), aInfo.position, 2, "Delete");

        }
    });
    mListView.setDismissCallback(new EnhancedListView.OnDismissCallback() {
        @Override
        public EnhancedListView.Undoable onDismiss(EnhancedListView listView, final int position) {

            final Meeting item = meetingAdpt.getItem(position);
            meetingAdpt.remove(item);
            return new EnhancedListView.Undoable() {
                @Override
                public void undo() {
                    meetingAdpt.insert(item, position);
                }

                @Override
                public String getTitle() {
                    return "Meeting deleted";
                }

                @Override
                public void discard() {
                    deleteMeeting(item);
                }
            };
        }
    });
    mListView.enableSwipeToDismiss();
    mListView.setSwipingLayout(R.id.list_meeting_item_frame_1);
    mListView.setSwipeDirection(EnhancedListView.SwipeDirection.BOTH);
}

From source file:com.ninetwozero.battlelog.fragments.PlatoonMemberFragment.java

public void createContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {

    // Get the actual menu item and tag
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    // Get the data
    PlatoonMemberData data = (PlatoonMemberData) info.targetView.getTag();

    // General//from  ww w.j a va 2s . c o  m
    menu.add(2, 0, 0, R.string.info_profile_view);

    // Let's see... founder? No "admin" options on that user!!
    if (data.getMembershipLevel() == 256) {

        return;

    }
    if (data.getMembershipLevel() >= 4) { // ^Other actual member

        // Are we on an admin level and able to modify?
        if (platoonInformation.isAdmin() && isViewingMembers) {

            // 128 == Admin, which renders our action to demote
            if (data.getMembershipLevel() == 128) {

                menu.add(2, 1, 0, R.string.info_platoon_member_demote);

            } else {

                menu.add(2, 1, 0, R.string.info_platoon_member_promote);

            }

            menu.add(2, 2, 0, R.string.info_platoon_member_kick);

        }

    } else if (data.getMembershipLevel() == 1) { // Players that want to
        // join

        menu.add(2, 3, 0, R.string.info_platoon_member_new_accept);
        menu.add(2, 4, 0, R.string.info_platoon_member_new_deny);

    }
    return;

}

From source file:com.droidvnteam.hexagonrom.GestureAnywhereBuilderActivity.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_EDIT, 0, R.string.ga_gestures_edit);
    menu.add(0, MENU_ID_REMOVE, 0, R.string.ga_gestures_delete);
}

From source file:info.guardianproject.notepadbot.NoteCipher.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    // menu.add(0, VIEW_ID, 0, R.string.menu_view);
    menu.add(0, SHARE_ID, 0, R.string.menu_share);
    menu.add(0, DELETE_ID, 0, R.string.menu_delete);

}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(getActivity(), sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);

    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfoIn;
    mAlbumCursor.moveToPosition(mi.position);
    mCurrentAlbumId = mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
    mCurrentAlbumName = mAlbumCursor//from w w  w  . j  av  a 2s.c om
            .getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
    mCurrentArtistNameForAlbum = mAlbumCursor
            .getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST));
    mIsUnknownArtist = mCurrentArtistNameForAlbum == null
            || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
    mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
    if (mIsUnknownAlbum) {
        menu.setHeaderTitle(getString(R.string.unknown_album_name));
    } else {
        menu.setHeaderTitle(mCurrentAlbumName);
    }
    if (!mIsUnknownAlbum || !mIsUnknownArtist) {
        menu.add(0, SEARCH, 0, R.string.search_title);
    }
}

From source file:org.opensmc.mytracks.cyclesmc.MainInput.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, CONTEXT_RETRY, 0, "Retry Upload");
    menu.add(0, CONTEXT_DELETE, 0, "Delete");
}

From source file:com.filepager.afilechooser.FileListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // TODO Auto-generated method stub
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    FileListAdapter adapter = (FileListAdapter) getListView().getAdapter();
    if (adapter != null) {
        File file = (File) adapter.getItem(info.position);
        if (!file.isDirectory()) {
            menu.setHeaderTitle(R.string.select_action);
            menu.add(Menu.NONE, 0, 0, "Send file to " + fileChooserActivity.hostname);
            menu.add(Menu.NONE, 1, 1, "Open");

        }//  ww  w  .  j ava2 s  .  c o  m

    }

    super.onCreateContextMenu(menu, v, menuInfo);
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (list.size() > 1) {
        menu.add(Menu.NONE, R.id.context_menu_quickaccess_move, 1, R.string.context_menu_move);
    }//from w  w  w.j  a v a  2s . c om
    QuickAccess.Entry entry = adapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
    if (entry.chan == null)
        return;
    menu.add(Menu.NONE, R.id.context_menu_quickaccess_remove, 2, R.string.context_menu_quickaccess_remove);
}

From source file:com.guayaba.tapir.ui.fragments.GenreFragment.java

/**
 * {@inheritDoc}/*from ww  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;
    // Create a new genre
    mGenre = mAdapter.getItem(info.position);
    // Create a list of the genre's songs
    mGenreList = MusicUtils.getSongListForGenre(getActivity(), mGenre.mGenreId);

    // Play the genre
    menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, R.string.context_menu_play_selection);
    // Add the genre to the queue
    menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, R.string.add_to_queue);
}