List of usage examples for android.view ContextMenu add
public MenuItem add(CharSequence title);
From source file:com.xabber.android.ui.helper.ContextMenuHelper.java
public static void createGroupContextMenu(final FragmentActivity activity, final UpdatableAdapter adapter, final String account, final String group, ContextMenu menu) { menu.setHeaderTitle(GroupManager.getInstance().getGroupName(account, group)); if (!group.equals(GroupManager.ACTIVE_CHATS) && !group.equals(GroupManager.IS_ROOM)) { menu.add(R.string.group_rename).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override// w ww . j a va2s . c o m public boolean onMenuItemClick(MenuItem item) { GroupRenameDialogFragment .newInstance(account.equals(GroupManager.NO_ACCOUNT) ? null : account, group.equals(GroupManager.NO_GROUP) ? null : group) .show(activity.getFragmentManager(), "GROUP_RENAME"); return true; } }); if (!group.equals(GroupManager.NO_GROUP)) { menu.add(R.string.group_remove).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { GroupDeleteDialogFragment .newInstance(account.equals(GroupManager.NO_ACCOUNT) ? null : account, group) .show(activity.getFragmentManager(), "GROUP_DELETE"); return true; } }); } } if (!group.equals(GroupManager.ACTIVE_CHATS)) { menu.add(R.string.show_offline_settings) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { createOfflineContactsDialog(activity, adapter, account, group).show(); return true; } }); } }
From source file:com.commonsware.android.arXiv.FavouritesListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(R.string.remove_favorites); }
From source file:tinygsn.gui.android.ActivityPullData.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { for (String s : SERVER_LIST) { menu.add(s); }/*from ww w . j ava 2 s . co m*/ }
From source file:com.commonsware.android.arXiv.CategoriesListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { menu.add(R.string.add_favorites); }
From source file:com.telestax.restcomm_olympus.MainFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == android.R.id.list) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; menu.setHeaderTitle("Edit '" + contactList.get(info.position).get("username") + "'"); menu.add("Update Contact"); menu.add("Remove Contact"); }/*from w ww. ja v a 2s .c om*/ }
From source file:org.tunesremote.PlaylistsFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; try {/*from w ww . jav a 2 s . co m*/ // create context menu to play entire artist final Playlist ply = (Playlist) adapter.getItem(info.position); menu.setHeaderTitle(ply.getName()); final String playlistid = Long.toString(ply.getID()); final MenuItem browse = menu.add(R.string.albums_menu_browse); browse.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(host, TracksActivity.class); intent.putExtra(Intent.EXTRA_TITLE, ""); intent.putExtra("Playlist", playlistid); intent.putExtra("PlaylistPersistentId", ply.getPersistentId()); intent.putExtra("AllAlbums", false); host.startActivityForResult(intent, 1); return true; } }); final MenuItem play = menu.add(R.string.playlists_menu_play); play.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { host.session.controlPlayPlaylist(ply.getPersistentId(), "0"); host.finish(); return true; } }); } catch (Exception e) { Log.w(TAG, "onCreateContextMenu:" + e.getMessage()); } }
From source file:org.mozilla.mozstumbler.client.serialize.KMLFragment.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final ListView list = (ListView) v; final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; final int position = info.position; final Object object = list.getAdapter().getItem(position); menu.add(R.string.load_file); menu.add(R.string.share_file);/*w ww .j av a 2s . c om*/ menu.add(R.string.delete_file); menu.add(R.string.delete_all); MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { contextItemSelected(item, (object == null) ? null : object.toString()); if (mLoadFileDialog != null && mLoadFileDialog.isShowing()) { mLoadFileDialog.dismiss(); } return false; } }; for (int i = 0, n = menu.size(); i < n; i++) menu.getItem(i).setOnMenuItemClickListener(listener); }
From source file:com.github.michalbednarski.intentslab.editor.BundleAdapter.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { final AdapterView.AdapterContextMenuInfo aMenuInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; if (aMenuInfo.position == mKeysCount) { return;//from www . ja v a 2 s . c om } menu.add(mOwnerFragment.getString(R.string.delete)) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final String key = mKeys[aMenuInfo.position]; if (mUseSandbox) { try { mSandboxedBundle.remove(key); } catch (RemoteException e) { e.printStackTrace(); // TODO: resandbox bundle } } else { mBundle.remove(key); } updateKeySet(); notifyDataSetChanged(); return true; } }); }
From source file:org.tunesremote.ArtistsListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; // create context menu to play entire artist try {/* www. j a va 2 s. c om*/ Response resp = (Response) adapter.getItem(info.position); final String artist = resp.getString("mlit"); menu.setHeaderTitle(artist); MenuItem play = menu.add(R.string.artists_menu_play); play.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { host.session.controlPlayArtist(artist, 0); host.setResult(Activity.RESULT_OK, new Intent()); host.finish(); return true; } }); MenuItem queue = menu.add(R.string.artists_menu_queue); queue.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { host.session.controlQueueArtist(artist); host.setResult(Activity.RESULT_OK, new Intent()); host.finish(); return true; } }); MenuItem browse = menu.add(R.string.artists_menu_browse); browse.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(host, AlbumsActivity.class); intent.putExtra(Intent.EXTRA_TITLE, artist); host.startActivityForResult(intent, 1); return true; } }); } catch (Exception e) { Log.w(TAG, "onCreateContextMenu:" + e.getMessage()); } }
From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { for (UiMenuItem item : mContextMenuItems) { MenuItem menuItem = menu.add(item.mmTitle); menuItem.setOnMenuItemClickListener(item.mmListener); }//from w w w . jav a2 s . c om }