Questions tagged [android-contextmenu]

Tag for questions about the creation and use of the Android context menu.

The context menu is a menu that appears after the user long clicked a widget on the screen. The typical scenario of building a context menu in Android is to register the desired view by calling the registerForContextMenu(using the View itself as a parameter) and then overriding the onCreateContextMenu callback of an Activity(the callback is also available for Fragments) to provide the menu to be shown. Extra information about the context menu can be found at:

198 questions
21
votes
4 answers

Android opening context menu after button click

I want to open context menu when I click a button, but also I have to know which list item is focused when I click the button. Do you know how to do that? What code should be in onclick method?
Mustafa İrer
  • 1,051
  • 5
  • 15
  • 29
21
votes
1 answer

getMenuInflater( ) method undefined issue in Android Context Menu creation

I am trying to create a context menu item inside a fragment. But I am facing issue with the getMenuInflater() method. It is undefined. I have imported all the necessary packages. Can anyone point out what I am doing wrong here? Here is my code:…
intrepidkarthi
  • 3,104
  • 8
  • 42
  • 75
18
votes
1 answer

Hide Items in Context Action Bar (CAB) dynamically when multiple items are selected

I have a listActivity that shows CAB on long click. If more than 1 item is selected I would like to hide one of my menu items. I keep track of the # of items selected in onItemCheckedStateChanged(). However I don't have access to the menu to…
Jeremy A. West
  • 2,162
  • 4
  • 27
  • 40
15
votes
2 answers

Triggering a PopupMenu with buttons inside a ListView item

Types of Menu Let me start by outlining the distinction between Contextual Menus and Popup Menus (taken from here): A PopupMenu is a modal menu anchored to a View A contextual menu [I'm talking specifically about floating context menus] offers…
ataulm
  • 15,195
  • 7
  • 50
  • 92
13
votes
3 answers

How can I tell if the input method picker is open or closed?

My app opens the input method picker (the menu where you choose a keyboard) with InputMethodManager.showInputMethodPicker(). My app doesn't actually create the picker (it's created by InputMethodManager) but I know it's a ContextMenu and its id is…
Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135
12
votes
1 answer

onContextItemSelected does not get called in a DialogFragment

I have a dialog that shows a list of items, I need to be able to edit/delete items in this list so I put a context menu in so when the user long presses on an item it they can choose what they want to do (edit or delete the item). The problem is…
tyczj
  • 71,600
  • 54
  • 194
  • 296
10
votes
2 answers

Inappropriate Context Menu within a Fragment

I have an activity with a Navigation Drawer and a fragment. Each of them has his own ListView with a Contextual Menu. The Context Menu inside the navigation drawer works fine. The problem is with the menu inside the fragment. When I enter the…
Dennis
  • 2,271
  • 6
  • 26
  • 42
9
votes
4 answers

Customise context menu like pinterest menu

I've been looking for something like Pinterest menu whenever item in GridView is pressed. I know it's too broad question. But little strike on question will provide a correct way to achieve these. Que: How one can implement customise context menu…
Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
9
votes
5 answers

contextual action mode in fragment - close if not focused?

i implemented a contextual action mode bar in a nested fragement. This fragment is part of a view pager and the view pager is also a fragment and part of a navigation drawer. My Problem: I want to close the contextual action mode bar if the fragment…
8
votes
2 answers

How to open Menu Context Android with click button in listview adapter?

How to open Menu Context Android with click button in listview adapter ? I tried with my code, but not show the menu context, code public View getView(int position, View convertView, ViewGroup parent) { vi=convertView; …
bukanamay
  • 577
  • 5
  • 11
  • 26
7
votes
1 answer

How to use MultiChoiceModeListener in ListVIew with and with out supports?

I am trying to add multi-select context menu to a listview with support library 22.1.1 using AppCompatActivity and Toolbar Without support library I can use AbsListView.MultiChoiceModeListener with support library, There is no equivalent…
6
votes
1 answer

How can we add a new context menu option to all the apps that would show up when user selects a text and long presses on it?

How can we add a new context menu option to all the apps that would show up when user selects a text and long presses on it? Let's say I want to provide user the capability of finding the meaning of a word from an offline dictionary without having…
cp1
  • 75
  • 1
  • 5
6
votes
1 answer

Enable/Disable item selection at listview in multiple choice mode

I have a listview registered for context menu in multiple choice mode: private void initListViewForContextMenu(){ log.d("FilesFragment", "initListViewForContextMenu()"); ListView listView = getListView(); …
jmhostalet
  • 4,399
  • 4
  • 38
  • 47
5
votes
6 answers

android:popupBackground not working for context menus

Why does my styles.xml code successfully change the background colour of my actionbar overflow menu, but fail to change the background colour of the context menu in my app?