Java Code Examples for android.view.ContextMenu#add()
The following examples show how to use
android.view.ContextMenu#add() .
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: FolderListActivity.java From opensudoku with GNU General Public License v3.0 | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info; try { info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return; } Cursor cursor = (Cursor) mListView.getAdapter().getItem(info.position); if (cursor == null) { // For some reason the requested item isn't available, do nothing return; } menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(FolderColumns.NAME))); menu.add(0, MENU_ITEM_EXPORT, 0, R.string.export_folder); menu.add(0, MENU_ITEM_RENAME, 1, R.string.rename_folder); menu.add(0, MENU_ITEM_DELETE, 2, R.string.delete_folder); }
Example 2
Source File: join.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 3
Source File: FeedListFragment.java From AnotherRSS with The Unlicense | 6 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo; Cursor c = (Cursor) adapter.getItem(info.position); // first item!! int flagVal = c.getInt(c.getColumnIndex(FeedContract.Feeds.COLUMN_Flag)); if (flagVal == FeedContract.Flag.FAVORITE) { menu.add(R.string.nofavorite); } else { menu.add(R.string.favorite); } MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.item_context, menu); }
Example 4
Source File: HistoryActivity.java From barcodescanner-lib-aar with MIT License | 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 5
Source File: ArchivePage.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 threadNumber = getAdapter().getItem(position).getThreadNumber(); menu.add(0, CONTEXT_MENU_COPY_LINK, 0, R.string.action_copy_link); if (!FavoritesStorage.getInstance().hasFavorite(pageHolder.chanName, pageHolder.boardName, threadNumber)) { menu.add(0, CONTEXT_MENU_ADD_FAVORITES, 0, R.string.action_add_to_favorites); } }
Example 6
Source File: AutohideActivity.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; if (info.position == 0) return; menu.add(Menu.NONE, R.id.context_menu_delete, 1, R.string.context_menu_delete_autohide_rule); }
Example 7
Source File: WidgetsDialogFragment.java From HgLauncher with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, @Nullable ContextMenu.ContextMenuInfo menuInfo) { // Set the calling view. callingView = (AppWidgetHostView) v; int index = appWidgetContainer.indexOfChild(v); // Workaround for DialogFragment issue with context menu. // Taken from: https://stackoverflow.com/a/18853634 MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onContextItemSelected(item); return true; } }; // Generate menu. // TODO: Maybe a more robust and automated way can be done for this. menu.clear(); menu.add(1, 0, 100, getString(R.string.action_remove_widget)); menu.add(1, 1, 100, getString(R.string.action_up_widget)); menu.add(1, 2, 100, getString(R.string.action_down_widget)); menu.getItem(0).setOnMenuItemClickListener(listener); // Move actions should only be added when there is more than one widget. menu.getItem(1).setVisible(appWidgetContainer.getChildCount() > 1 && index > 0); menu.getItem(2).setVisible(appWidgetContainer.getChildCount() != index + 1); if (appWidgetContainer.getChildCount() > 1) { if (index > 0) { menu.getItem(1).setOnMenuItemClickListener(listener); } if (index + 1 != appWidgetContainer.getChildCount()) { menu.getItem(2).setOnMenuItemClickListener(listener); } } }
Example 8
Source File: UserBoardsPage.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, int position, View targetView) { 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(getPageHolder().chanName, boardName, null)) { menu.add(0, CONTEXT_MENU_ADD_FAVORITES, 0, R.string.action_add_to_favorites); } } }
Example 9
Source File: FavoriteAdapter.java From android-popular-movies-app with Apache License 2.0 | 5 votes |
/** * When the user performs a long-click on a favorite movie item, a floating menu appears. * * Reference @see "https://stackoverflow.com/questions/36958800/recyclerview-getmenuinfo-always-null" * "https://stackoverflow.com/questions/37601346/create-options-menu-for-recyclerview-item" */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int adapterPosition = getAdapterPosition(); // Set the itemId to adapterPosition to retrieve movieEntry later MenuItem item = menu.add(DELETE_GROUP_ID, adapterPosition, DELETE_ORDER, v.getContext().getString(R.string.action_delete)); item.setOnMenuItemClickListener(this); }
Example 10
Source File: FilterFriendsChooseLeadersFragment.java From PADListener with GNU General Public License v2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { MyLog.entry("menuInfo = " + menuInfo); final MonsterInfoModel monsterInfo = getGroupMonsterItem(menuInfo); menu.setHeaderTitle(getActivity().getString(R.string.filter_friends_choose_leaders_context_menu_all_title, monsterInfo.getName())); menu.add(0, MENU_ID_DESELECT_ALL, 0, R.string.filter_friends_choose_leaders_context_menu_all_deselect); menu.add(0, MENU_ID_SELECT_ALL, 0, R.string.filter_friends_choose_leaders_context_menu_all_select); MyLog.exit(); }
Example 11
Source File: HistoryPage.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, int position, View targetView) { HistoryDatabase.HistoryItem historyItem = getAdapter().getHistoryItem(position); if (historyItem != null) { menu.add(0, CONTEXT_MENU_COPY_LINK, 0, R.string.action_copy_link); if (!FavoritesStorage.getInstance().hasFavorite(historyItem.chanName, historyItem.boardName, historyItem.threadNumber)) { menu.add(0, CONTEXT_MENU_ADD_FAVORITES, 0, R.string.action_add_to_favorites); } menu.add(0, CONTEXT_MENU_REMOVE_FROM_HISTORY, 0, R.string.action_remove_from_history); } }
Example 12
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 13
Source File: FragmentTransactionsAbstract.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.setHeaderTitle(R.string.trans_menu_title); menu.add(0, 100, 0, R.string.trans_menu_changename);//groupId, itemId, order, title menu.add(0, 101, 0, R.string.trans_menu_viewreceiver); menu.add(0, 102, 0, R.string.trans_menu_openinb); }
Example 14
Source File: MainActivity.java From TapUnlock with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(getResources().getString(R.string.rename_context_menu)); menu.add(getResources().getString(R.string.delete_context_menu)); }
Example 15
Source File: HistoryActivity.java From zxingfragmentlib 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 16
Source File: PhotoAdapter.java From abelana with Apache License 2.0 | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, R.id.context_menu_report, Menu.NONE, R.string .context_menu_report); }
Example 17
Source File: ActivityDlgActions.java From LibreTasks with Apache License 2.0 | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; menu.setHeaderTitle(adapterActions.getItem(info.position).getDescription()); menu.add(ContextMenu.NONE, MENU_INFO, ContextMenu.NONE, R.string.info); }
Example 18
Source File: GalleryFragment.java From imsdk-android with MIT License | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(0, SAVE_TO_GALLERY, 0, R.string.atom_ui_menu_save_image); menu.add(0, SIGNOTIFICATE_QR_CODE, 0, R.string.atom_ui_menu_scan_qrcode); isLongClick = true; }
Example 19
Source File: WorkWorldBrowersingFragment.java From imsdk-android with MIT License | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(0, SAVE_TO_GALLERY, 0, R.string.atom_ui_menu_save_image); menu.add(0, SIGNOTIFICATE_QR_CODE, 0, R.string.atom_ui_menu_scan_qrcode); isLongClick = true; }
Example 20
Source File: Gallery1.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.add(R.string.gallery_2_text); }