What is the difference between Menu and Context Menu? How they are creating in android, menu including edit, delete, copy and many other option in android. here, by using list items during creating context menu and menu.
There are three types of Menus
Option Menu (If you click on Hardware Menu button your option menu will come into play)
Context Menu (If you long click on any list item in list view (your context menu will come into play we have to register context menu to work)
SubMenu
Related
I got a menu with a single menu item. When I click the 3 dots menu icon in the action bar, a drop down list is opened to show the single item there is to choose.
How can I automatically handle that menu item as the user clicks the menu icon, without showing the drop down list (meaning the menu item should be chosen automatically for the user)?
You can use onMenuOpened to override the behavior:
onMenuOpened
added in API level 1 boolean onMenuOpened (int featureId,
Menu menu) Called when a panel's menu is opened by the user. This may also be called when the menu is changing from one type
to another (for example, from the icon menu to the expanded menu).
What are the differences between Context menu vs Popup menu vs bottom sheet?
and what kind of situations they are best fit for?
Option Menu Option Menus are the primary menus of android. They can be used for settings, search, delete item etc. we are inflating the menu by calling the inflate() method of MenuInflater class. To perform event handling on menu items, you need to override onOptionsItemSelected() method of Activity class.
Context Menu Android context menu appears when user press long click on the element. It is also known as floating menu.
Bottom sheets bottom sheet is a sheet of material that slides up from the bottom edge of the screen and presents a set of clear and simple actions
Please read this SO Answer difference-between-context-menu-and-option-menu-in-android
Bottom sheet is an Android component that present anchored views at the bottom of the screen. It became popular on Android 5, you can find more information in the Material Design documentation.
Popup menu is a dialog box linked to a concrete element in the UI, with it you can implement the Quick Actions UI pattern.
⦁ Pop-up menu/context Menu - A context menu (also called contextual, shortcut, and popup or pop-up menu) is a menu in a graphical user interface (GUI) that appears upon user interaction, such as a right-click mouse operation.
⦁ Fall-down menu - move the mouse over the menu to open it. In a computer, a drop-down menu is a menu that offers a list of options. The title of the menu, of the currently-selected item in the list, is always displayed. When the visible item is clicked, other items from the list "drop-down" into view, and the user can choose from those options.
I am using Action bar and having menu items implemented using Action Provider. Clicking on menu item shows Popup Spinner. Now when any Menu item is clicked and Popup screen is ON and that time - If Overflow menu item is clicked then it doesn't show menu items under Overflow list (I need to click once again to get Overflow menu items).
Is this known issue? Is there any workaround for this?
Is this known issue?
It's known. It is not an issue. The drop-down for list navigation (what I presume the "Popup Spinner" is) has the focus. It takes a tap outside of the drop-down, anywhere in the activity, to dismiss the drop-down.
This is not significantly different than the behavior of a Spinner anywhere else in Android. For example, edit a contact, and tap on the Spinner to change a phone number type (e.g., mobile vs. home vs. work). It takes a tap anywhere else to dismiss the drop-down list, before a tap will have any other meaning.
Is there any workaround for this?
Do not use list navigation or other Spinners in your app.
What are the differences between the following types of menus in Android?
option menu
context menu
sub menu
Can anyone give me an explanation and an example for each?
Option menu: The menu that appears when you press the menu button
Context menu: The menu that appears like a dialog with a list when you (mostly) longpress on list elements
Sub menu: can be used to display more menu items with your option menu.
More details: http://developer.android.com/guide/topics/ui/menus.html
Can you please tell me the difference between context menu and option menu in android?
When I click the menu button on the emulator, is that option menu? or context menu?
And how to invoke the other menu (not trigger by the menu button)?
Thank you.
When I click the menu button on the
emulator, is that option menu?
Yes.
And how to invoke the other menu (not
trigger by the menu button)?
By long-tapping on whatever widget (if any) has a context menu.
The page on UI Guidelines and Menu Design in the Android documentation gives a good explaination of each of the types of menus.
Two line summary:
Options Menu - the menu you see when pressing the 'Menu' button
Context Menu - the menu shown when you press and hold an item.
Google provides an extensive summary of the different menu types in their documentation.
Excerpt:
Options menu and action bar
The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings."
If you're developing for Android 2.3 or lower, users can reveal the options menu panel by pressing the Menu button.
On Android 3.0 and higher, items from the options menu are presented by the action bar as a combination of on-screen action items and overflow options. Beginning with Android 3.0, the Menu button is deprecated (some devices don't have one), so you should migrate toward using the action bar to provide access to actions and other options.
Context menu and contextual action mode
A context menu is a floating menu that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame.
When developing for Android 3.0 and higher, you should instead use the contextual action mode to enable actions on selected content. This mode displays action items that affect the selected content in a bar at the top of the screen and allows the user to select multiple items.