List of usage examples for android.view ContextMenu add
public MenuItem add(int groupId, int itemId, int order, CharSequence title);
From source file:info.staticfree.android.units.Units.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.add(Menu.NONE, MENU_REEDIT, Menu.FIRST, R.string.ctx_menu_reedit); menu.add(Menu.NONE, MENU_COPY, Menu.CATEGORY_SYSTEM, android.R.string.copy); menu.add(Menu.NONE, MENU_SEND, Menu.CATEGORY_SYSTEM, R.string.ctx_menu_send); menu.add(Menu.NONE, MENU_USE_RESULT, Menu.CATEGORY_SECONDARY, R.string.ctx_menu_use_result); }
From source file:org.yammp.fragment.ArtistFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) { ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) info; int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition); mSelectedGroupPosition = ExpandableListView.getPackedPositionGroup(mi.packedPosition); int gpos = mSelectedGroupPosition; if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { mGroupSelected = true;/*from ww w . ja v a 2 s . c o m*/ mChildSelected = false; mGroupCursor.moveToPosition(gpos); menu.add(hashCode(), PLAY_SELECTION, 0, R.string.play_selection); menu.add(hashCode(), DELETE_ITEMS, 0, R.string.delete_music); menu.add(hashCode(), DELETE_LYRICS, 0, R.string.delete_lyrics); if (gpos == -1) { // this shouldn't happen Log.d("Artist/Album", "no group"); return; } mCurrentGroupArtistName = mGroupCursor.getString(mGroupArtistIdx); mSelectedGroupId = mGroupCursor.getLong(mGroupArtistIdIdx); if (mCurrentGroupArtistName != null && !MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) { menu.setHeaderTitle(mCurrentGroupArtistName); menu.add(hashCode(), SEARCH, 0, android.R.string.search_go); } else { menu.setHeaderTitle(getString(R.string.unknown_artist)); } } }
From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (menuInfo instanceof AdapterView.AdapterContextMenuInfo) { AdapterView.AdapterContextMenuInfo itemInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; TextView textView = (TextView) itemInfo.targetView.findViewById(R.id.listitem_name); if (textView != null) { menu.setHeaderTitle(textView.getText()); }/* ww w .j a v a 2 s .co m*/ Object listItem = getListAdapter().getItem(itemInfo.position); if (listItem instanceof Cursor) { menu.add(0, MENU_STATS, 0, R.string.menu_statistics); menu.add(0, MENU_SHARE, 0, R.string.menu_shareTrack); menu.add(0, MENU_RENAME, 0, R.string.menu_renameTrack); menu.add(0, MENU_DELETE, 0, R.string.menu_deleteTrack); } } }
From source file:com.xorcode.andtweet.TweetListActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); // Get the adapter context menu information AdapterView.AdapterContextMenuInfo info; try {//from w ww. j av a2 s. c om info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return; } int m = 0; // Add menu items menu.add(0, CONTEXT_MENU_ITEM_REPLY, m++, R.string.menu_item_reply); menu.add(0, CONTEXT_MENU_ITEM_RETWEET, m++, R.string.menu_item_retweet); menu.add(0, CONTEXT_MENU_ITEM_SHARE, m++, R.string.menu_item_share); // menu.add(0, CONTEXT_MENU_ITEM_DIRECT_MESSAGE, m++, // R.string.menu_item_direct_message); // menu.add(0, CONTEXT_MENU_ITEM_UNFOLLOW, m++, // R.string.menu_item_unfollow); // menu.add(0, CONTEXT_MENU_ITEM_BLOCK, m++, R.string.menu_item_block); // menu.add(0, CONTEXT_MENU_ITEM_PROFILE, m++, // R.string.menu_item_view_profile); // Get the record for the currently selected item Uri uri = ContentUris.withAppendedId(Tweets.CONTENT_URI, info.id); Cursor c = getContentResolver().query(uri, new String[] { Tweets._ID, Tweets.MESSAGE, Tweets.AUTHOR_ID, Tweets.FAVORITED }, null, null, null); try { c.moveToFirst(); menu.setHeaderTitle(c.getString(c.getColumnIndex(Tweets.MESSAGE))); if (c.getInt(c.getColumnIndex(Tweets.FAVORITED)) == 1) { menu.add(0, CONTEXT_MENU_ITEM_DESTROY_FAVORITE, m++, R.string.menu_item_destroy_favorite); } else { menu.add(0, CONTEXT_MENU_ITEM_FAVORITE, m++, R.string.menu_item_favorite); } if (MyPreferences.getDefaultSharedPreferences().getString(MyPreferences.KEY_TWITTER_USERNAME, null) .equals(c.getString(c.getColumnIndex(Tweets.AUTHOR_ID)))) { menu.add(0, CONTEXT_MENU_ITEM_DESTROY_STATUS, m++, R.string.menu_item_destroy_status); } } catch (Exception e) { Log.e(TAG, "onCreateContextMenu: " + e.toString()); } finally { if (c != null && !c.isClosed()) c.close(); } }
From source file:com.mahali.gpslogger.MainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v.getId() == R.id.sessionListView) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; menu.setHeaderTitle(sessionList.get(info.position).getFileName()); String[] menuItems = getResources().getStringArray(R.array.sessionLongMenu); for (int i = 0; i < menuItems.length; i++) { menu.add(Menu.NONE, i, i, menuItems[i]); }// w w w.j av a 2s. co m } }
From source file:mobisocial.musubi.ui.fragments.FeedListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (v.getId() == android.R.id.list) { menu.setHeaderTitle("Feed..."); menu.add(Menu.NONE, 0, 0, "Delete"); menu.add(Menu.NONE, 1, 0, "Send HTML"); }/* w w w . ja va 2 s. c o m*/ }
From source file:moe.johnny.tombstone.ui.PreventFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (!canCreateContextMenu(menu, menuInfo)) { return;/* w w w. ja v a 2 s .c o m*/ } menu.clear(); ViewHolder holder = (ViewHolder) ((AdapterContextMenuInfo) menuInfo).targetView.getTag(); menu.setHeaderTitle(holder.nameView.getText()); if (holder.icon != null) { setHeaderIcon(menu, holder.icon); } menu.add(Menu.NONE, R.string.app_info, Menu.NONE, R.string.app_info); if (holder.checkView.isEnabled() || canPreventAll()) { updatePreventMenu(menu, holder.packageName); } if (getMainIntent(holder.packageName) != null) { menu.add(Menu.NONE, R.string.open, Menu.NONE, R.string.open); } if (holder.canUninstall) { menu.add(Menu.NONE, R.string.uninstall, Menu.NONE, R.string.uninstall); } if (appNotification) { menu.add(Menu.NONE, R.string.app_notifications, Menu.NONE, R.string.app_notifications); } }
From source file:com.android.mms.quickmessage.QuickMessagePopup.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.clear();/*from w w w . j a v a 2s .c om*/ // Templates menu item, if there are defined templates if (mNumTemplates > 0) { menu.add(0, MENU_ADD_TEMPLATE, 0, R.string.template_insert).setIcon(android.R.drawable.ic_menu_add) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } // Add to Blacklist item (if enabled) and we are running on CyanogenMod // This allows the app to be run on non-blacklist enabled roms (including Stock) if (MessageUtils.isCyanogenMod(this)) { if (BlacklistUtils.isBlacklistEnabled(this)) { menu.add(0, MENU_ADD_TO_BLACKLIST, 0, R.string.add_to_blacklist) .setIcon(R.drawable.ic_block_message_holo_dark) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } }
From source file:com.todoroo.astrid.core.CustomFilterActivity.java
private void setUpListeners() { ((Button) findViewById(R.id.add)).setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja va 2 s .c om*/ public void onClick(View v) { listView.showContextMenu(); } }); final Button saveAndView = ((Button) findViewById(R.id.saveAndView)); saveAndView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveAndView(); } }); filterName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { saveAndView.setText(R.string.CFA_button_view); saveAndView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.tango_next, 0); } else { saveAndView.setText(R.string.CFA_button_save); saveAndView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.tango_save, 0); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (menu.hasVisibleItems()) { /* If it has items already, then the user did not click on the "Add Criteria" button, but instead long held on a row in the list view, which caused CustomFilterAdapter.onCreateContextMenu to be invoked before this onCreateContextMenu method was invoked. */ return; } int i = 0; for (CustomFilterCriterion item : criteria.values()) { try { menu.add(CustomFilterActivity.MENU_GROUP_FILTER, i, 0, item.name); } catch (NullPointerException e) { throw new NullPointerException("One of the criteria is null. Criteria: " + criteria); //$NON-NLS-1$ } i++; } } }); }
From source file:com.ninetwozero.battlelog.fragments.ForumThreadFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { // Show the menu menu.add(0, 0, 0, R.string.info_profile_view); menu.add(0, 1, 0, R.string.info_forum_quote); menu.add(0, 2, 0, R.string.info_forum_links); menu.add(0, 3, 0, R.string.info_forum_report); // RETURN/*w w w .j a va2 s . c o m*/ return; }