List of usage examples for android.view ContextMenu setHeaderTitle
public ContextMenu setHeaderTitle(CharSequence title);
From source file:org.yammp.app.TrackFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) { if (mCursor == null) return;/*from www.j a v a2 s .c o m*/ getActivity().getMenuInflater().inflate(R.menu.music_browser_item, menu); AdapterContextMenuInfo adapterinfo = (AdapterContextMenuInfo) info; mSelectedPosition = adapterinfo.position; mCursor.moveToPosition(mSelectedPosition); try { mSelectedId = mCursor.getLong(mIdIdx); } catch (IllegalArgumentException ex) { mSelectedId = adapterinfo.id; } mCurrentAlbumName = mCursor.getString(mAlbumIdx); mCurrentArtistNameForAlbum = mCursor.getString(mArtistIdx); mCurrentTrackName = mCursor.getString(mTrackIdx); menu.setHeaderTitle(mCurrentTrackName); }
From source file:com.balakrish.gpstracker.WaypointsListActivity.java
/** * Create context menu for selected item *///from w w w . ja v a 2 s . c o m @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // AdapterView.AdapterContextMenuInfo info = // (AdapterView.AdapterContextMenuInfo) menuInfo; menu.setHeaderTitle(getString(R.string.waypoint)); menu.add(Menu.NONE, 0, 0, R.string.edit); menu.add(Menu.NONE, 1, 1, R.string.delete); menu.add(Menu.NONE, 2, 2, R.string.email_to); menu.add(Menu.NONE, 3, 3, R.string.show_on_map); }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.FavouriteStopsFragment.java
/** * {@inheritDoc}//from w ww . ja v a 2 s . co m */ @Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Get the menu inflater. final MenuInflater inflater = getActivity().getMenuInflater(); final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; final Cursor c = (Cursor) ca.getItem(info.position); final String selectedStopCode; // Get the stopCode. if (c != null) { selectedStopCode = String.valueOf(c.getString(0)); } else { selectedStopCode = ""; } // Set the header title of the context menu. menu.setHeaderTitle(getString(R.string.busstop, sd.getNameForStop(selectedStopCode), selectedStopCode)); // Inflate the menu from XML. inflater.inflate(R.menu.favouritestops_context_menu, menu); // Set the title of the proximity alert item depending whether one is // set or not. MenuItem item = menu.findItem(R.id.favouritestops_context_menu_prox_alert); if (sd.isActiveProximityAlert(selectedStopCode)) { item.setTitle(R.string.favouritestops_menu_prox_rem); } else { item.setTitle(R.string.favouritestops_menu_prox_add); } // Set the title of the time alert item depending whether one is set or // not. item = menu.findItem(R.id.favouritestops_context_menu_time_alert); if (sd.isActiveTimeAlert(selectedStopCode)) { item.setTitle(R.string.favouritestops_menu_time_rem); } else { item.setTitle(R.string.favouritestops_menu_time_add); } // If the Google Play Services is not available, then don't show the // option to show the stop on the map. item = menu.findItem(R.id.favouritestops_context_menu_showonmap); if (!GenericUtils.isGoogleMapsAvailable(getActivity())) { item.setVisible(false); } }
From source file:in.andres.kandroid.ui.TaskDetailActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.comment_listview) { menu.setHeaderTitle(getString(R.string.menu_caption_comment, ((KanboardComment) commentListview .getAdapter().getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)).getId())); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_taskdetail_context_comment, menu); }/* w w w . j av a 2 s. co m*/ if (v.getId() == R.id.subtask_listview) { menu.setHeaderTitle(getString(R.string.menu_caption_subtask, ((KanboardSubtask) subtaskListview .getAdapter().getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position)).getId())); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_taskdetail_context_subtask, menu); } }
From source file:com.nachiket.titan.LibraryActivity.java
/** * Creates a context menu for an adapter row. * * @param menu The menu to create./* w ww .j ava2 s . c om*/ * @param rowData Data for the adapter row. */ public void onCreateContextMenu(ContextMenu menu, Intent rowData) { if (rowData.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID) == LibraryAdapter.HEADER_ID) { menu.setHeaderTitle(getString(R.string.all_songs)); menu.add(0, MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); menu.add(0, MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData); menu.addSubMenu(0, MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); } else { int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID); boolean isAllAdapter = type <= MediaUtils.TYPE_SONG; menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE)); menu.add(0, MENU_PLAY, 0, R.string.play).setIntent(rowData); if (isAllAdapter) menu.add(0, MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); menu.add(0, MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData); if (isAllAdapter) menu.add(0, MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData); if (type == MediaUtils.TYPE_PLAYLIST) { menu.add(0, MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData); menu.add(0, MENU_EXPAND, 0, R.string.edit).setIntent(rowData); } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) { menu.add(0, MENU_EXPAND, 0, R.string.expand).setIntent(rowData); } if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG) menu.add(0, MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData); if (type == MediaUtils.TYPE_SONG) menu.add(0, MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData); menu.addSubMenu(0, MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); menu.add(0, MENU_DELETE, 0, R.string.delete).setIntent(rowData); } }
From source file:com.todoroo.astrid.activity.FilterListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; Filter item = adapter.getItem(info.position); android.view.MenuItem menuItem; if (item instanceof Filter) { Filter filter = (Filter) item; menuItem = menu.add(0, CONTEXT_MENU_SHORTCUT, 0, R.string.FLA_context_shortcut); menuItem.setIntent(ShortcutActivity.createIntent(filter)); }/* w w w . java 2s . c om*/ for (int i = 0; i < item.contextMenuLabels.length; i++) { if (item.contextMenuIntents.length <= i) break; menuItem = menu.add(0, CONTEXT_MENU_INTENT, 0, item.contextMenuLabels[i]); menuItem.setIntent(item.contextMenuIntents[i]); } if (menu.size() > 0) menu.setHeaderTitle(item.listingTitle); }
From source file:org.bombusim.lime.fragments.RosterFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); int pos = ((AdapterContextMenuInfo) menuInfo).position; contextItem = getListAdapter().getItem(pos); if (contextItem instanceof RosterGroup) { //TODO: context menu for group return;/*www. j ava 2 s. c o m*/ } if (contextItem instanceof XmppAccount) { //TODO: context menu for account return; } if (contextItem instanceof Contact) { Contact c = (Contact) contextItem; menu.setHeaderTitle(c.getScreenName()); Drawable icon = new BitmapDrawable(c.getAvatar()); menu.setHeaderIcon(icon); MenuInflater inflater = getActivity().getMenuInflater(); if (contextItem instanceof SelfContact) { inflater.inflate(R.menu.contact_self_menu, menu); } else { inflater.inflate(R.menu.contact_menu, menu); } //enable items available only if logged in menu.setGroupEnabled(R.id.groupLoggedIn, sb.isLoggedIn(c.getRosterJid())); return; } }
From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryDetail.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info; try {//w w w.j a v a 2 s. c o m info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (final ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return; } // XXX the "- 1" below is due to having a header. I'm not sure where this is supposed to be handled. final Cursor c = (Cursor) mCastAdapter.getItem(info.position - 1); if (c == null) { return; } // load the base menus. final MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.cast_context, menu); menuInflater.inflate(R.menu.cast_options, menu); menu.setHeaderTitle(c.getString(c.getColumnIndex(Cast._TITLE))); final boolean canEdit = Cast.canEdit(this, c); menu.findItem(R.id.cast_edit).setVisible(canEdit); menu.findItem(R.id.cast_delete).setVisible(canEdit); }
From source file:com.pdftron.pdf.controls.UserBookmarkDialogFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == R.id.controls_bookmark_recycler_view) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; UserBookmarkItem item = mBookmarkViewAdapter.getItem(info.position); menu.setHeaderTitle(item.title); String[] menuItems = getResources().getStringArray(R.array.user_bookmark_dialog_context_menu); menu.add(Menu.NONE, CONTEXT_MENU_EDIT_ITEM, CONTEXT_MENU_EDIT_ITEM, menuItems[CONTEXT_MENU_EDIT_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ITEM, CONTEXT_MENU_DELETE_ITEM, menuItems[CONTEXT_MENU_DELETE_ITEM]); menu.add(Menu.NONE, CONTEXT_MENU_DELETE_ALL, CONTEXT_MENU_DELETE_ALL, menuItems[CONTEXT_MENU_DELETE_ALL]); MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override//from w w w .ja va2 s . c o m public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }; menu.getItem(CONTEXT_MENU_EDIT_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ITEM).setOnMenuItemClickListener(listener); menu.getItem(CONTEXT_MENU_DELETE_ALL).setOnMenuItemClickListener(listener); } }
From source file:hku.fyp14017.blencode.ui.fragment.SoundFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (SoundController.getInstance().isSoundPlaying(mediaPlayer)) { SoundController.getInstance().stopSoundAndUpdateList(mediaPlayer, soundInfoList, adapter); }//from w ww . ja v a 2s . c om selectedSoundInfo = adapter.getItem(selectedSoundPosition); menu.setHeaderTitle(selectedSoundInfo.getTitle()); adapter.addCheckedItem(((AdapterContextMenuInfo) menuInfo).position); getSherlockActivity().getMenuInflater().inflate(hku.fyp14017.blencode.R.menu.context_menu_default, menu); menu.findItem(hku.fyp14017.blencode.R.id.context_menu_copy).setVisible(true); menu.findItem(hku.fyp14017.blencode.R.id.context_menu_unpacking).setVisible(false); }