List of usage examples for android.view ContextMenu add
public MenuItem add(int groupId, int itemId, int order, CharSequence title);
From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatView.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); /* Get the list item position. */ AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; Cursor cursor = (Cursor) mAdapter.getItem(info.position); menu.add(0, GROUPCHAT_MENU_ITEM_DELETE, 0, R.string.menu_delete_message); Direction direction = Direction.valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(Message.DIRECTION))); if (Direction.OUTGOING == direction) { menu.add(0, GROUPCHAT_MENU_ITEM_VIEW_GC_INFO, 1, R.string.menu_view_groupdelivery); // TODO depending on mime-type and provider ID, allow user to view file image }/* w w w . ja v a 2 s . c o m*/ }
From source file:com.ovrhere.android.currencyconverter.ui.fragments.MainFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (v.getId() == R.id.currConv_main_listView) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; CurrencyData currency = outputListAdapter.getItem(info.position); if (currency != null) { String title = getString(R.string.currConv_context_currencyAction, currency.getCurrencyCode()); menu.setHeaderTitle(title);//from ww w . j a v a2s .c om menu.add(Menu.CATEGORY_SECONDARY, 0, 0, android.R.string.copy); menu.add(Menu.CATEGORY_SECONDARY, 1, 1, R.string.currConv_context_detailedCopy); } } }
From source file:net.voxcorp.voxmobile.ui.account.AccountsEditListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final SipProfile account = profileFromContextMenuInfo(menuInfo); if (account == null) { return;//from ww w .j a v a2 s. c o m } WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard); // Setup the menu header menu.setHeaderTitle(account.display_name); if (wizardInfos != null) { menu.setHeaderIcon(wizardInfos.icon); } menu.add(0, MENU_ITEM_ACTIVATE, 0, account.active ? R.string.deactivate_account : R.string.activate_account); menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account); menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account); if (!VoXMobile.isVoXMobile(account.proxies)) { menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard); } }
From source file:mobisocial.musubi.ui.fragments.ContactsFragment.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Cursor c = (Cursor) mContacts.getItem(info.position); long identityId = c.getLong(c.getColumnIndexOrThrow(MIdentity.COL_ID)); MIdentity ident = mIdentityManager.getIdentityForId(identityId); String[] menuItems;/*from w w w. ja va2 s . c o m*/ if (ident.type_ == Authority.Email && !ident.claimed_) { menuItems = new String[] { "Ignore", "Invite" }; } else { menuItems = new String[] { "Ignore" }; } for (int i = 0; i < menuItems.length; i++) { menu.add(GROUP_ID, i, i, menuItems[i]); } }
From source file:com.code.android.vibevault.SearchScreen.java
/** Called when the activity is first created. */ @Override//from w w w. j ava2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_screen); this.searchList = (ListView) this.findViewById(R.id.ResultsListView); this.artistSearchInput = (AutoCompleteTextView) this.findViewById(R.id.ArtistSearchBox); this.yearSearchInput = (EditText) this.findViewById(R.id.YearSearchBox); this.dateModifierSpinner = (Spinner) this.findViewById(R.id.DateSearchSpinner); this.searchButton = (Button) this.findViewById(R.id.SearchButton); this.settingsButton = (Button) this.findViewById(R.id.SettingsButton); //this.searchMoreButton = (Button) this.findViewById(R.id.SearchMoreButton); this.clearButton = (Button) this.findViewById(R.id.ClearButton); this.searchDrawer = (SlidingDrawer) this.findViewById(R.id.SlidingDrawerSearchScreen); this.handleText = (TextView) this.findViewById(R.id.HandleTextView); vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); searchList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Show"); menu.add(Menu.NONE, VibeVault.SHOW_INFO, Menu.NONE, "Show Info"); menu.add(Menu.NONE, VibeVault.ADD_TO_FAVORITE_LIST, Menu.NONE, "Bookmark Show"); } }); Object retained = getLastNonConfigurationInstance(); if (retained instanceof JSONQueryTask) { workerTask = (JSONQueryTask) retained; workerTask.setActivity(this); } else { workerTask = new JSONQueryTask(this); } if (VibeVault.searchResults.size() != 0) { searchButton.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.morebutton), null, null, null); searchButton.setText("More"); //this.clearButton.setEnabled(true); } else { searchButton.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.searchbutton_plain), null, null, null); searchButton.setText("Search"); } this.init(); Intent intent = getIntent(); if (intent.hasExtra("Artist")) { browseArtist(intent.getStringExtra("Artist")); } if (!VibeVault.db.getPref("artistUpdate").equals("2010-01-01")) { artistSearchInput.setAdapter( new ArrayAdapter<String>(this, R.layout.artist_search_row, VibeVault.db.getArtistsStrings())); } if (VibeVault.searchPref.equals("Show/Artist Description") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Descriptions..."); } }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Creates a context menu for an adapter row. * * @param menu The menu to create./*from ww w . ja v a2s. co m*/ * @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, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); menu.add(0, CTX_MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData); menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); } else { int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID); menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE)); if (FileUtils.canDispatchIntent(rowData)) menu.add(0, CTX_MENU_OPEN_EXTERNAL, 0, R.string.open).setIntent(rowData); menu.add(0, CTX_MENU_PLAY, 0, R.string.play).setIntent(rowData); if (type <= MediaUtils.TYPE_SONG) { menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); } menu.add(0, CTX_MENU_ENQUEUE_AS_NEXT, 0, R.string.enqueue_as_next).setIntent(rowData); menu.add(0, CTX_MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData); if (type == MediaUtils.TYPE_PLAYLIST) { menu.add(0, CTX_MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData); } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) { menu.add(0, CTX_MENU_EXPAND, 0, R.string.expand).setIntent(rowData); } if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG) menu.add(0, CTX_MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData); if (type == MediaUtils.TYPE_SONG) menu.add(0, CTX_MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData); menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); menu.add(0, CTX_MENU_DELETE, 0, R.string.delete).setIntent(rowData); } }
From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; // take cursor and move into position Cursor cursor = ((CurrencyListAdapter) getListAdapter()).getCursor(); cursor.moveToPosition(info.position); // set currency name menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(Currency.CURRENCYNAME))); // compose context menu String[] menuItems = getResources().getStringArray(R.array.context_menu_currencies); for (int i = 0; i < menuItems.length; i++) { menu.add(Menu.NONE, i, i, menuItems[i]); }//from w w w. j a v a 2s. co m }
From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java
/** * Creates a context menu for an adapter row. * * @param menu The menu to create.//from w w w. j a v a 2 s . com * @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, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); menu.add(0, CTX_MENU_ENQUEUE_ALL, 0, R.string.enqueue_all).setIntent(rowData); menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); } else { int type = rowData.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID); menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE)); if (FileUtils.canDispatchIntent(rowData)) menu.add(0, CTX_MENU_OPEN_EXTERNAL, 0, R.string.open).setIntent(rowData); menu.add(0, CTX_MENU_PLAY, 0, R.string.play).setIntent(rowData); if (type <= MediaUtils.TYPE_SONG) { menu.add(0, CTX_MENU_PLAY_ALL, 0, R.string.play_all).setIntent(rowData); } menu.add(0, CTX_MENU_ENQUEUE_AS_NEXT, 0, R.string.enqueue_as_next).setIntent(rowData); menu.add(0, CTX_MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData); if (type == MediaUtils.TYPE_PLAYLIST) { menu.add(0, CTX_MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData); } else if (rowData.getBooleanExtra(LibraryAdapter.DATA_EXPANDABLE, false)) { menu.add(0, CTX_MENU_EXPAND, 0, R.string.expand).setIntent(rowData); } if (type == MediaUtils.TYPE_ALBUM || type == MediaUtils.TYPE_SONG) menu.add(0, CTX_MENU_MORE_FROM_ARTIST, 0, R.string.more_from_artist).setIntent(rowData); if (type == MediaUtils.TYPE_SONG) { menu.add(0, CTX_MENU_MORE_FROM_ALBUM, 0, R.string.more_from_album).setIntent(rowData); if (PluginUtils.checkPlugins(this)) menu.add(0, CTX_MENU_PLUGINS, 1, R.string.plugins).setIntent(rowData); // last in order } menu.addSubMenu(0, CTX_MENU_ADD_TO_PLAYLIST, 0, R.string.add_to_playlist).getItem().setIntent(rowData); menu.add(0, CTX_MENU_DELETE, 0, R.string.delete).setIntent(rowData); } }
From source file:de.electricdynamite.pasty.ClipboardFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (v.getId() == R.id.listItems || v.getId() == R.id.listItemText) { menu.setHeaderTitle(getString(R.string.itemContextMenuTitle)); String[] menuItems = getResources().getStringArray(R.array.itemContextMenu); ClipboardItem mItem = mAdapter.getItem(info.position); if (mItem.isLinkified()) { /* Item was Linkified. * Let's add a "open in browser" menuItem *///from w ww . ja va2 s . c o m menu.add(Menu.NONE, PastySharedStatics.ITEM_CONTEXTMENU_OPEN_ID, 0, R.string.itemContextMenu_open); } for (int i = 0; i < menuItems.length; i++) { menu.add(Menu.NONE, i, i, menuItems[i]); } } }
From source file:joshuatee.wx.USWarningsWithRadarActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); String zone = map_button_zone.get(v.getId()); menu.add(0, v.getId(), 0, "Open radar interface"); menu.add(0, v.getId(), 0, "Open radar mosaic"); menu.add(0, v.getId(), 0, "Show radar products"); menu.add(0, v.getId(), 0, "Add new location for this warning (" + zone + ")"); }