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:joshuatee.wx.NEXRADAttributesActivity.java

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

    String county = map_button_county.get(v.getId());
    String state = map_button_state.get(v.getId());
    menu.add(0, v.getId(), 0, "Add new location for " + county + ", " + state);

}

From source file:com.boko.vimusic.ui.fragments.GenreFragment.java

/**
 * {@inheritDoc}//  www  .j av  a2s. 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.getId());

    // 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);
}

From source file:com.meetingninja.csse.notes.NotesFragment.java

private void setupViews(View v) {
    // setup listview
    ListView lv = (ListView) v.findViewById(R.id.notesList);
    noteAdpt = new NoteArrayAdapter(getActivity(), R.layout.list_item_note, notes);
    lv.setAdapter(noteAdpt);/* w ww.j  a  va 2  s .c  om*/

    // pretty images are better than boring text
    notesImageButton = (ImageButton) v.findViewById(android.R.id.empty);
    lv.setEmptyView(notesImageButton);
    notesImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            createNote();
        }
    });

    // Item click event
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parentAdapter, View v, int position, long id) {
            Note clickedNote = noteAdpt.getItem(position);

            Intent editNote = new Intent(getActivity(), ViewNoteActivity.class);
            editNote.putExtra("listPosition", position);
            editNote.putExtra(Keys.Note.PARCEL, clickedNote);
            startActivityForResult(editNote, 1);

        }
    });

    // make list long-pressable
    registerForContextMenu(lv);

    // Item long-click event
    // TODO: Add additional options and click-events to these options
    lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;

            Note n = noteAdpt.getItem(aInfo.position);
            menu.setHeaderTitle("Options for " + "'" + n.getTitle().trim() + "'");
            menu.add(MainActivity.DrawerLabel.NOTES.getPosition(), aInfo.position, 1, "Add Content");
            menu.add(MainActivity.DrawerLabel.NOTES.getPosition(), aInfo.position, 2, "Delete");
            menu.add(MainActivity.DrawerLabel.NOTES.getPosition(), aInfo.position, 3, "Version Control");
            menu.add(MainActivity.DrawerLabel.NOTES.getPosition(), aInfo.position, 4, "Merge");
        }

    });
}

From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatList.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    /* Check file transfer API is connected */
    if (!isServiceConnected(RcsServiceName.CHAT)) {
        showMessage(R.string.label_service_not_available);
        return;//from w w  w.j a  v  a 2s.  c om
    }
    menu.add(0, CHAT_MENU_ITEM_OPEN, CHAT_MENU_ITEM_OPEN, R.string.menu_open_chat_session);
    menu.add(0, CHAT_MENU_ITEM_DELETE, CHAT_MENU_ITEM_DELETE, R.string.menu_delete_chat_session);
}

From source file:org.kaaproject.kaa.demo.smarthousedemo.smarthouse.DevicesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.devicesList) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        SmartDeviceInfo device = mDevicesAdapter.getItem(info.position);
        menu.setHeaderTitle(device.getDeviceName());
        String[] menuItems = getResources().getStringArray(R.array.deviceContextMenu);
        for (int i = 0; i < menuItems.length; i++) {
            menu.add(getDeviceType().ordinal(), i, i, menuItems[i]);
        }//from   w w  w . jav a2s .c  o m
    }
}

From source file:com.ame.armymax.SearchActivity.java

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

    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) menuInfo;

    // We know that each row in the adapter is a Map
    DataSearchResult planet = adapter.getItem(aInfo.position);

    menu.setHeaderTitle("Options for " + planet.getName());
    menu.add(1, 1, 1, "Details");
    menu.add(1, 2, 2, "Delete");

}

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

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

From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsListFragment.java

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    if (info.position >= 0) {
        menu.add(0, MENU_VIEW, 0, R.string.menu_view);
        menu.add(0, MENU_DELETE, 0, R.string.menu_delete);
    }/*w ww  .j  a  v a2  s  .c o m*/
}

From source file:com.android.music.AlbumBrowserActivity.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(this, 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  ww. j  a v a2s . 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:joshuatee.wx.LocationFragment.java

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

    switch (v.getId()) {
    case R.id.forecast_generic_status:
        menu.add(0, v.getId(), 0, "Edit Location..");
        break;/*  w ww  .  j  av a 2s  . co  m*/
    }

}