List of usage examples for android.view ContextMenu add
public MenuItem add(int groupId, int itemId, int order, CharSequence title);
From source file:org.smap.smapTask.android.activities.MainMapsActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (currentPlace != null) { int taskId = currentPlace.getId(); // Use currentPlace to get task Id Cursor c = null;/* ww w . jav a 2s.co m*/ fda = new FileDbAdapter(); try { fda.open(); c = fda.fetchTaskForId((long) taskId); String taskStatus = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS)); String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE)); menu.setHeaderTitle(taskTitle); if (fda.canReject(taskStatus)) { menu.add(0, R.id.reject, 0, R.string.smap_reject_task); } if (fda.canComplete(c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS)))) { menu.add(0, R.id.complete_task, 0, R.string.smap_complete_task); } if (fda.canAccept(taskStatus)) { menu.add(0, R.id.accept_task, 0, R.string.smap_accept_task); } menu.add(0, R.id.cancel_task, 0, R.string.cancel); } catch (Exception e) { e.printStackTrace(); } finally { if (fda != null) { fda.close(); } if (c != null) { c.close(); } } } else { } }
From source file:com.todoroo.astrid.activity.TaskListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo; Task task = ((ViewHolder) adapterInfo.targetView.getTag()).task; if (task.getValue(Task.IS_READONLY) > 0) return;//from www. j a va 2s . c om int id = (int) task.getId(); menu.setHeaderTitle(task.getValue(Task.TITLE)); if (task.isDeleted()) { menu.add(id, CONTEXT_MENU_UNDELETE_TASK_ID, Menu.NONE, R.string.TAd_contextUndeleteTask); menu.add(id, CONTEXT_MENU_PURGE_TASK_ID, Menu.NONE, R.string.TAd_contextPurgeTask); } else { menu.add(id, CONTEXT_MENU_EDIT_TASK_ID, Menu.NONE, R.string.TAd_contextEditTask); menu.add(id, CONTEXT_MENU_COPY_TASK_ID, Menu.NONE, R.string.TAd_contextCopyTask); for (int i = 0; i < contextItemExposers.length; i++) { Object label = contextItemExposers[i].getLabel(task); if (label != null) { if (label instanceof Integer) menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (Integer) label); else menu.add(id, CONTEXT_MENU_PLUGIN_ID_FIRST + i, Menu.NONE, (String) label); } } long taskId = task.getId(); for (ContextMenuItem item : contextMenuExtensionLoader.getList()) { android.view.MenuItem menuItem = menu.add(id, CONTEXT_MENU_BROADCAST_INTENT_ID, Menu.NONE, item.title); item.intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId); menuItem.setIntent(item.intent); } menu.add(id, CONTEXT_MENU_DELETE_TASK_ID, Menu.NONE, R.string.TAd_contextDeleteTask); } }
From source file:mp.teardrop.LibraryActivity.java
/** * Creates a context menu for an adapter row. * * @param menu The menu to create.// w ww. j av a2 s.com * @param rowData Data for the adapter row. */ public void onCreateContextMenu(ContextMenu menu, Intent rowData) { if (rowData == null) { return; } 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; boolean isAllAdapter = false; //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) { if(false) { menu.add(0, MENU_RENAME_PLAYLIST, 0, R.string.rename).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.gh4a.fragment.EventListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.list_view) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Event event = (Event) mAdapter.getItem(info.position); int groupId = getMenuGroupId(); //if payload is a base class, return void. Think that it is an old event which not supported //by API v3. if (event.getPayload().getClass().getSimpleName().equals("EventPayload")) { return; }//from w w w . ja v a 2 s .co m String eventType = event.getType(); EventRepository eventRepo = event.getRepo(); String[] repoNamePart = eventRepo.getName().split("/"); String repoOwner = null; String repoName = null; if (repoNamePart.length == 2) { repoOwner = repoNamePart[0]; repoName = repoNamePart[1]; } String repoUrl = eventRepo.getUrl(); menu.setHeaderTitle("Go to"); /** Common menu */ menu.add(groupId, MENU_USER, Menu.NONE, "User " + event.getActor().getLogin()); if (repoOwner != null) { menu.add(groupId, MENU_REPO, Menu.NONE, "Repo " + repoOwner + "/" + repoName); } /** PushEvent extra menu for commits */ if (Event.TYPE_PUSH.equals(eventType)) { if (repoOwner != null) { PushPayload payload = (PushPayload) event.getPayload(); menu.add(groupId, MENU_COMPARE, Menu.NONE, "Compare " + payload.getHead()); List<Commit> commits = payload.getCommits(); for (Commit commit : commits) { menu.add(groupId, MENU_COMMIT, Menu.NONE, "Commit " + commit.getSha()); } } } /** IssueEvent extra menu for commits */ else if (Event.TYPE_ISSUES.equals(eventType)) { IssuesPayload payload = (IssuesPayload) event.getPayload(); menu.add(groupId, MENU_ISSUE, Menu.NONE, "Issue " + payload.getIssue().getNumber()); } /** FollowEvent */ else if (Event.TYPE_FOLLOW.equals(eventType)) { FollowPayload payload = (FollowPayload) event.getPayload(); if (payload.getTarget() != null) { menu.add(groupId, MENU_USER, Menu.NONE, "User " + payload.getTarget().getLogin()); } } /** CommitCommentEvent */ else if (Event.TYPE_COMMIT_COMMENT.equals(eventType)) { if (repoOwner != null) { CommitCommentPayload payload = (CommitCommentPayload) event.getPayload(); menu.add(groupId, MENU_COMMIT, Menu.NONE, "Commit " + payload.getComment().getCommitId().substring(0, 7)); //menu.add("Comment in browser"); } } /** GistEvent */ else if (Event.TYPE_GIST.equals(eventType)) { GistPayload payload = (GistPayload) event.getPayload(); menu.add(groupId, MENU_GIST, Menu.NONE, "Gist " + payload.getGist().getId()); } /** DownloadEvent */ else if (Event.TYPE_DOWNLOAD.equals(eventType)) { DownloadPayload payload = (DownloadPayload) event.getPayload(); menu.add(groupId, MENU_FILE, Menu.NONE, "File " + payload.getDownload().getName()); } /** ForkEvent */ else if (Event.TYPE_FORK.equals(eventType)) { ForkPayload payload = (ForkPayload) event.getPayload(); Repository forkee = payload.getForkee(); if (forkee != null) { menu.add(groupId, MENU_FORKED_REPO, Menu.NONE, "Forked repo " + forkee.getOwner().getLogin() + "/" + forkee.getName()); } } /** GollumEvent */ else if (Event.TYPE_GOLLUM.equals(eventType)) { menu.add(groupId, MENU_WIKI_IN_BROWSER, Menu.NONE, "Wiki in browser"); } /** PullRequestEvent */ else if (Event.TYPE_PULL_REQUEST.equals(eventType)) { PullRequestPayload payload = (PullRequestPayload) event.getPayload(); menu.add(groupId, MENU_PULL_REQ, Menu.NONE, "Pull request " + payload.getNumber()); } /** IssueCommentEvent */ else if (Event.TYPE_ISSUE_COMMENT.equals(eventType)) { menu.add(groupId, MENU_OPEN_ISSUES, Menu.NONE, "Open issues"); } } }
From source file:in.shick.diode.threads.ThreadsListActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info; info = (AdapterView.AdapterContextMenuInfo) menuInfo; ThingInfo _item = mThreadsAdapter.getItem(info.position); mVoteTargetThing = _item;/*w ww. j ava2 s .com*/ menu.add(0, Constants.VIEW_SUBREDDIT_CONTEXT_ITEM, 0, R.string.view_subreddit); menu.add(0, Constants.SHARE_CONTEXT_ITEM, 0, R.string.share); menu.add(0, Constants.OPEN_IN_BROWSER_CONTEXT_ITEM, 0, R.string.open_browser); if (mSettings.isLoggedIn()) { if (!_item.isSaved()) { menu.add(0, Constants.SAVE_CONTEXT_ITEM, 0, "Save"); } else { menu.add(0, Constants.UNSAVE_CONTEXT_ITEM, 0, "Unsave"); } menu.add(0, Constants.HIDE_CONTEXT_ITEM, 0, "Hide"); } // Make sure the user isn't '[deleted]' if (!_item.isDeletedUser()) { menu.add(0, Constants.DIALOG_VIEW_PROFILE, Menu.NONE, String.format(getResources().getString(R.string.user_profile), _item.getAuthor())); } }
From source file:jackpal.androidterm.Term.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle(R.string.edit_text); menu.add(0, SELECT_TEXT_ID, 0, R.string.select_text); menu.add(0, COPY_ALL_ID, 0, R.string.copy_all); menu.add(0, PASTE_ID, 0, R.string.paste); // menu.add(0, SEND_CONTROL_KEY_ID, 0, R.string.send_control_key); // menu.add(0, SEND_FN_KEY_ID, 0, R.string.send_fn_key); menu.add(0, SEND_MENU_ID, 0, R.string.title_functionbar_menu); // menu.add(0, SEND_FUNCTION_BAR_ID, 0, R.string.toggle_function_bar); if (!canPaste()) { menu.getItem(PASTE_ID).setEnabled(false); }/* w w w . ja v a2 s . c o m*/ }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.upload_target) { if (passThrough) return; menu.clear();//from w ww . j av a 2s. c o m DatabaseHelper db = new DatabaseHelper(ActivityUploader.this); db.getFavorites(ids, names); db.close(); menu.setHeaderTitle(" ?"); for (int i = 0; i < names.size(); ++i) menu.add(MENU_GROUP_SELECT_GALLERY, i, 0, names.get(i)); menu.add(MENU_GROUP_SELECT_GALLERY, MENU_ADD_GALLERY, 0, " ..."); } else if (v.getId() == R.id.upload_visit) { menu.clear(); if (pageDestination.equals("dcinside")) { visitPage(MENU_DCINSIDE); } else if (pageDestination.equals("mobile")) { visitPage(MENU_MOBILE); } else { menu.setHeaderTitle(" ?"); String dest; if (mobilePageProvider.equals("moolzo")) dest = ""; else dest = "DCmys"; menu.add(MENU_GROUP_VISIT, MENU_DCINSIDE, 0, "??"); menu.add(MENU_GROUP_VISIT, MENU_MOBILE, 0, dest); } } }
From source file:org.uguess.android.sysinfo.ProcessManager.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); int pos = ((AdapterContextMenuInfo) menuInfo).position; ProcessItem rap = (ProcessItem) getListView().getItemAtPosition(pos); menu.setHeaderTitle(R.string.actions); menu.add(Menu.NONE, MI_DISPLAY, Menu.NONE, R.string.switch_to); boolean protect = ignoreList.contains(rap.procInfo.processName) || rap.sys; if (protect) { menu.add(Menu.NONE, MI_ENDTASK, Menu.NONE, R.string.end_task).setEnabled(false); } else {/*ww w . j a v a 2 s .c o m*/ menu.add(Menu.NONE, MI_ENDTASK, Menu.NONE, R.string.end_task); } menu.add(Menu.NONE, MI_END_OTHERS, Menu.NONE, R.string.end_others); if (protect) { menu.add(Menu.NONE, MI_IGNORE, Menu.NONE, R.string.ignore).setEnabled(false); } else { menu.add(Menu.NONE, MI_IGNORE, Menu.NONE, R.string.ignore); } menu.add(Menu.NONE, MI_DETAILS, Menu.NONE, R.string.details); }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.setHeaderTitle(R.string.actions); menu.add(Menu.NONE, MI_MANAGE, Menu.NONE, R.string.manage); menu.add(Menu.NONE, MI_LAUNCH, Menu.NONE, R.string.run); menu.add(Menu.NONE, MI_SEARCH, Menu.NONE, R.string.search_market); menu.add(Menu.NONE, MI_DETAILS, Menu.NONE, R.string.details); }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, DELETE_ID, 0, R.string.menu_delete); }