android.view.ContextMenu Java Examples
The following examples show how to use
android.view.ContextMenu.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicroBlogContextMenuListener.java From YiBo with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Adapter adapter = lvMicroBlog.getAdapter(); this.position = info.position; targetView = info.targetView; Status status= (Status)adapter.getItem(position); if (status == null || (status instanceof LocalStatus && ((LocalStatus)status).isDivider())) { return; } Context context = v.getContext(); analyzeStatusMenu(adapter, status, menu, context); }
Example #2
Source File: FilesFragment.java From odyssey with GNU General Public License v3.0 | 6 votes |
/** * Create the context menu. */ @Override public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; FileModel currentFile = mAdapter.getItem(info.position); if (currentFile.isFile()) { // show context menu for files inflater.inflate(R.menu.context_menu_files_files_fragment, menu); // hide enqueue as next for playlist files menu.findItem(R.id.fragment_files_action_enqueueasnext).setVisible(!currentFile.isPlaylist()); } else { // show context menu for directories inflater.inflate(R.menu.context_menu_directories_files_fragment, menu); } }
Example #3
Source File: AccountsEditListFragment.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); final SipProfile account = profileFromContextMenuInfo(menuInfo); if(account == null) { return; } 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); menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard); }
Example #4
Source File: ChooseSyncSimpleContextMenuHelper.java From PADListener with GNU General Public License v2.0 | 6 votes |
public void createContextMenu(ContextMenu menu, ContextMenu.ContextMenuInfo menuInfo) { MyLog.entry("menuInfo = " + menuInfo); final ChooseModelContainer<SyncedMonsterModel> monsterItem = getMonsterItem(menuInfo); menu.setHeaderTitle(getContext().getString(R.string.choose_sync_context_menu_one_title, monsterItem.getModel().getDisplayedMonsterInfo().getName())); if (monsterItem.isChosen()) { menu.add(getGroupId(), MENU_ID_DESELECT, 0, R.string.choose_sync_context_menu_one_deselect); } else { menu.add(getGroupId(), MENU_ID_SELECT, 0, R.string.choose_sync_context_menu_one_select); } if (getMode() != SyncMode.DELETED) { menu.add(getGroupId(), MENU_ID_CHANGE_PRIORITY, 0, R.string.choose_sync_context_menu_one_change_priority); menu.add(getGroupId(), MENU_ID_CHANGE_NOTE, 0, R.string.choose_sync_context_menu_one_change_note); } if (new DefaultSharedPreferencesHelper(getContext()).isChooseSyncUseIgnoreListForMonsters(getMode())) { menu.add(getGroupId(), MENU_ID_ADD_TO_IGNORE_LIST, 0, R.string.choose_sync_context_menu_one_add_to_ignore_list); } MyLog.exit(); }
Example #5
Source File: PreventFragment.java From prevent with Do What The F*ck You Want To Public License | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { if (!canCreateContextMenu(menu, menuInfo)) { return; } 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); 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); } }
Example #6
Source File: RecentTabsRowAdapter.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override void onCreateContextMenuForChild(final int childPosition, ContextMenu menu, Activity activity) { if (isMoreButton(childPosition)) return; OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.closeTab(getChild(childPosition)); return true; } }; menu.add(R.string.close_tab).setOnMenuItemClickListener(listener); }
Example #7
Source File: AllTasksListFragment.java From ActivityLauncher with ISC License | 6 votes |
@Override public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenuInfo menuInfo) { menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut); menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch); ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; ExpandableListView list = getView().findViewById(R.id.expandableListView1); switch (ExpandableListView.getPackedPositionType(info.packedPosition)) { case ExpandableListView.PACKED_POSITION_TYPE_CHILD: MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition)); menu.setHeaderIcon(activity.icon); menu.setHeaderTitle(activity.name); menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit); break; case ExpandableListView.PACKED_POSITION_TYPE_GROUP: MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition)); menu.setHeaderIcon(pack.icon); menu.setHeaderTitle(pack.name); break; } super.onCreateContextMenu(menu, v, menuInfo); }
Example #8
Source File: RecentTabsPage.java From delion with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // Would prefer to have this context menu view managed internal to RecentTabsGroupView // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener // disables the native onClick (expand/collapse) behaviour of the group view. ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView.getPackedPositionType(info.packedPosition); int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition); mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu, mActivity); } }
Example #9
Source File: MenuMainDemoFragment.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { TextView contextMenuTextView = (TextView) v; Context context = getContext(); menu.add(android.R.string.copy) .setOnMenuItemClickListener( item -> { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText(CLIP_DATA_LABEL, contextMenuTextView.getText())); return true; }); menu.add(R.string.context_menu_highlight) .setOnMenuItemClickListener( item -> { highlightText(contextMenuTextView); return true; }); }
Example #10
Source File: FragmentSummary.java From fingen with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater menuInflater = Objects.requireNonNull(getActivity()).getMenuInflater(); menuInflater.inflate(R.menu.context_menu_summary, menu); final MenuItem item = menu.findItem(R.id.action_show_report); ((ToolbarActivity) getActivity()).unsubscribeOnDestroy( mBillingService.getReportsIapInfo() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( skuDetailsWrapper -> { if (skuDetailsWrapper.isPurchased()) { item.setVisible(true); } else { item.setVisible(false); } }, throwable -> item.setVisible(false))); }
Example #11
Source File: ActivityMain.java From uPods-android with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); if (contextMenuType == ContextMenuType.PODCAST_MIDDLE_SCREEN) { inflater.inflate(R.menu.menu_basic_sceleton, menu); menu.add(getString(R.string.about_podcast)); if (((Podcast) currentContextMenuData).isDownloaded) { menu.add(getString(R.string.open_on_disk)); menu.add(getString(R.string.remove_all_episods)); } } else if (contextMenuType == ContextMenuType.EPISODE_MIDDLE_SCREEN) { inflater.inflate(R.menu.menu_basic_sceleton, menu); menu.add(getString(R.string.marks_as_played)); Track track = ((MediaItem.MediaItemBucket) currentContextMenuData).track; if (((Episode) track).isDownloaded) { menu.add(getString(R.string.delete)); } } else if (contextMenuType == ContextMenuType.PROFILE) { inflater.inflate(R.menu.menu_logedin_profile, menu); } else { inflater.inflate(R.menu.menu_activity_main, menu); } }
Example #12
Source File: AuthenticatorActivity.java From google-authenticator-android with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; PinInfo selectedUser = users[(int) info.id]; getMenuInflater().inflate(R.menu.account_list_context, menu); menu.setHeaderTitle(selectedUser.getIndex().getStrippedName()); if (!isRenameAccountAvailableSupported(selectedUser)) { menu.removeItem(R.id.rename); } if (!isCheckAccountKeyValueSupported(selectedUser)) { menu.removeItem(R.id.check_code); } mostRecentContextMenu = menu; }
Example #13
Source File: ProfileEdit.java From Favorite-Android-Client with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { //Log.i("ContextMenu", "Contextmenu"); if (v.getId() == R.id.profile_image) { menu.setHeaderIcon(android.R.drawable.btn_star); // menu.setHeaderTitle("공지사항"); menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.choose_picture)); menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.camera)); menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.delete)); } super.onCreateContextMenu(menu, v, menuInfo); }
Example #14
Source File: ChooseSyncGroupedContextMenuHelper.java From PADListener with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private ChooseModelContainer<SyncedMonsterModel> getChildMonsterItem(ContextMenu.ContextMenuInfo menuInfo) { MyLog.entry("menuInfo = " + menuInfo); final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition); int childPosition = ExpandableListView.getPackedPositionChild(listItem.packedPosition); final ChooseModelContainer result = adapter.getChild(groupPosition, childPosition); MyLog.exit(); return result; }
Example #15
Source File: RecordingsAdapter.java From go-bees with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { // Inflate menu menuInflater.inflate(R.menu.recording_item_menu, contextMenu); // Set click listener for (int i = 0; i < contextMenu.size(); i++) { contextMenu.getItem(i).setOnMenuItemClickListener(this); } }
Example #16
Source File: MonitorMangAty.java From Huochexing12306 with Apache License 2.0 | 5 votes |
private void setListViewContextMenuWithDel_Resume() { lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position; menu.add(0, 0, 0, "删除"); menu.add(0, 1, 1, "恢复所有已暂停车次"); } }); }
Example #17
Source File: AlbumsFragment.java From odyssey with GNU General Public License v3.0 | 5 votes |
/** * Create the context menu. */ @Override public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.context_menu_albums_fragment, menu); }
Example #18
Source File: HistoryActivity.java From weex with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position; if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) { menu.add(Menu.NONE, position, position, R.string.history_clear_one_history_text); } // else it's just that dummy "Empty" message }
Example #19
Source File: MainActivity.java From AndroidDemo with MIT License | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (v == myMenu) { menu.add(0, 1, 0, "私信"); menu.add(0, 2, 0, "查看"); menu.add(0, 3, 0, "删除"); } super.onCreateContextMenu(menu, v, menuInfo); }
Example #20
Source File: ChooseSyncGroupedContextMenuHelper.java From PADListener with GNU General Public License v2.0 | 5 votes |
private MonsterInfoModel getGroupMonsterItem(ContextMenu.ContextMenuInfo menuInfo) { MyLog.entry("menuInfo = " + menuInfo); final ExpandableListView.ExpandableListContextMenuInfo listItem = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; final int groupPosition = ExpandableListView.getPackedPositionGroup(listItem.packedPosition); final MonsterInfoModel result = adapter.getGroup(groupPosition); MyLog.exit(); return result; }
Example #21
Source File: GenresFragment.java From mobile-manager-tool with MIT License | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.add(mFragmentGroupId, ADD_TO_LOVE, 0, getResources().getString(R.string.play_all)); mCurrentId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID)); String title = mCursor.getString(mCursor.getColumnIndexOrThrow(Audio.Genres.NAME)); menu.setHeaderTitle(title); }
Example #22
Source File: PlaylistsFragment.java From mobile-manager-tool with MIT License | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterContextMenuInfo mi = (AdapterContextMenuInfo)menuInfo; menu.add(mFragmentGroupId, PLAY_SELECTION, 0, getResources().getString(R.string.play_all)); if (mi.id >= 0) { menu.add(mFragmentGroupId, RENAME_PLAYLIST, 0, getResources().getString(R.string.rename_playlist)); menu.add(mFragmentGroupId, DELETE_PLAYLIST, 0, getResources().getString(R.string.delete_playlist)); } mCurrentId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID)); String title = mCursor.getString(mCursor.getColumnIndexOrThrow(PlaylistsColumns.NAME)); menu.setHeaderTitle(title); }
Example #23
Source File: PreventFragment.java From prevent with Do What The F*ck You Want To Public License | 5 votes |
private void setHeaderIcon(ContextMenu menu, Drawable icon) { int width = getHeaderIconWidth(); if (icon.getMinimumWidth() <= width) { menu.setHeaderIcon(icon); } else if (icon instanceof BitmapDrawable) { Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) icon).getBitmap(), width, width, false); menu.setHeaderIcon(new BitmapDrawable(getResources(), bitmap)); } }
Example #24
Source File: BoardsPage.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, int position, View targetView) { PageHolder pageHolder = getPageHolder(); String boardName = getAdapter().getItem(position).boardName; if (boardName != null) { menu.add(0, CONTEXT_MENU_COPY_LINK, 0, R.string.action_copy_link); if (!FavoritesStorage.getInstance().hasFavorite(pageHolder.chanName, boardName, null)) { menu.add(0, CONTEXT_MENU_ADD_FAVORITES, 0, R.string.action_add_to_favorites); } } }
Example #25
Source File: FragmentFriendList.java From ploggy with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); if (view.equals(getListView())) { getActivity().getMenuInflater().inflate(R.menu.friend_list_context, menu); } }
Example #26
Source File: OPDSActivity.java From document-viewer with GNU General Public License v3.0 | 5 votes |
protected void onCreateFeedContextMenu(final ContextMenu menu, final Feed feed) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.opds_feedmenu, menu); menu.setHeaderTitle(getFeedTitle(feed)); updateMenuItems(menu, feed.parent); ActionMenuHelper.setMenuParameters(getController(), menu, new Constant("feed", feed)); }
Example #27
Source File: BrowserActivity.java From document-viewer with GNU General Public License v3.0 | 5 votes |
protected void createFileMenu(final ContextMenu menu, final String path) { final BookSettings bs = SettingsManager.getBookSettings(path); final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.book_menu, menu); menu.setHeaderTitle(path); menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null); menu.findItem(R.id.bookmenu_openbookshelf).setVisible(false); menu.findItem(R.id.bookmenu_openbookfolder).setVisible(false); final MenuItem om = menu.findItem(R.id.bookmenu_open); final SubMenu osm = om != null ? om.getSubMenu() : null; if (osm == null) { return; } osm.clear(); final List<Bookmark> list = new ArrayList<Bookmark>(); list.add(new Bookmark(true, getString(R.string.bookmark_start), PageIndex.FIRST, 0, 0)); list.add(new Bookmark(true, getString(R.string.bookmark_end), PageIndex.LAST, 0, 1)); if (bs != null) { if (LengthUtils.isNotEmpty(bs.bookmarks)) { list.addAll(bs.bookmarks); } list.add(new Bookmark(true, getString(R.string.bookmark_current), bs.currentPage, bs.offsetX, bs.offsetY)); } Collections.sort(list); for (final Bookmark b : list) { addBookmarkMenuItem(osm, b); } }
Example #28
Source File: PrivateMessageListFragment.java From something.apk with MIT License | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; FastItem item = adapter.getItem(info.position); if (item instanceof PrivateMessageItem) { getActivity().getMenuInflater().inflate(R.menu.pm_item, menu); } }
Example #29
Source File: ChooseSyncGroupedContextMenuHelper.java From PADListener with GNU General Public License v2.0 | 5 votes |
public void createContextMenu(ContextMenu menu, ContextMenu.ContextMenuInfo menuInfo) { MyLog.entry("menuInfo = " + menuInfo); if (isGroup(menuInfo)) { createContextMenuForGroup(menu, menuInfo); } else { createContextMenuForChild(menu, menuInfo); } MyLog.exit(); }
Example #30
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 5 votes |
void onCreateContextMenu(final CallVoid3<ContextMenu, View, ContextMenuInfo> superCall, ContextMenu menu, View v, ContextMenuInfo menuInfo) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); onCreateContextMenu(menu, v, menuInfo); } }