I have an editText that triggers the regular android context menu to fire up on long press. The talkback focus though doesn't go to the context menu directly but instead goes through other focusable elements first before focusing on the context menu. Basically is there a way to access the default context menu (marked as 2) in android and give focus to it first after long press instead of talkback moving to other elements (marked as 1)?
sample SS
I can show a context menu this is great.
Now I don't want the user to be able to close the context menu without choosing an option how would I go about doing this?
Or should I stop being lazy and move to a dialog?
There is no public API to control back-key behavior on context menu.
As you suggested your best option is to move to dialogs.
I have created a widget in my application , now when a widget is clicked I want to show few options in a context menu and allow the user to choose one of them.
My widget contains icon and text , so when a user click over an icon of widget i want to show the context menu.
is there a way to do it ? i am using android 2.3.X and android support compatibility package too.
here is what i want
The widget that i have created is derived from AppWidgetProvider class.
I think there is no way to open a context menu when we click on widget.
But alternatively we can open an activity instead and make it transparent then open a dialog box which contains ListView in that way we can mimic the look of context menu.
That is how i eventually did in my application.
How would I go about adding a context menu to a spinner popup?
I have a spinner that is populated by a database cursor, and I'd like to have a context menu so when the user long clicks an item they can edit or delete the item (two options in context menu).
I can't seem to find a way to register a context menu for the window that appears with the selectable items. Is there a way to, like on a list View?
Otherwise, what about having a hidden view that is registered for a context menu and then use the spinner's OnItemLongClickListener call openContextMenu for the hidden view? This seems kind of like a hack so I'd rather do it the correct way, if possible.
Or maybe I should just register the spinner for the context menu instead of having a hidden one...
Thanks!
How would I go about adding a context menu to a spinner popup?
Ideally, you wouldn't even try. Classic pop-up context menus are going to be obsolete with the new Honeycomb UI, at least for the tablet form factor, so I would not invest a ton of time in hacking them into widgets where they aren't normally used.
Moreover, users are unlikely to discover your context menu, simply because they tend not to discover context menus too often in the first place. Users tend not to experiment by randomly stabbing the screen for a second-plus to see if menus happen to pop up. The only way they will know about your context menu is if they read the fine manual, and we all know how often that happens. Hence, you need some other way for the user to do the same operations -- having them be able to edit/delete only through a non-discoverable context menu is very user-hostile. Hence, context menus are, at best, an accelerant, and not worth forcing into unexpected and unsupported places.
I have a spinner that is populated by a database cursor, and I'd like to have a context menu so when the user long clicks an item they can edit or delete the item (two options in context menu).
If you want the context menu, convert the Spinner into a ListView. Not only will this be incrementally more discoverable (some users will be used to interesting things if they long-tap on a list item), but context menus work naturally.
If you really want, you can clone Spinner (and possibly AbsSpinner or other superclasses) into your project, so you can take control over the drop-down behavior, then write something that enables a context menu on the selection dialog box. Then, you will need to bear in mind that none of that will work, most likely, with the new Spinner in Android 3.0, simply because there is no more selection dialog box.
I have a context menu on a TextView representing a user name in my app. When the context menu appears I want to have certain options such as View Statistics etc. The context menu is appearing fine and everything is working great except it's adding Input method to the context menu and I do not want it there. It's irrelevant to what the context menu is there for and there is not text entry. How can I remove this item from the context menu? I've tried removing item 0 in the context menu and adding
android:editable="false"
to the XML file to no avail. Any ideas?
How about menu.removeItem(android.R.id.switchInputMethod);?
Im pretty sure that isn't possible, the input method is how the user changes the current IME (soft keyboard) if the have multiple keyboards installed. Its a global setting.