Difference between context menu and option menu in android - android

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.

Related

Menu android in material desing

How create menu
https://www.google.com/design/spec/components/menus.html#menus-usage
The is PopupMenu or Spinnet?
The menu shown with the contacts is simply an Options menu as defined in the SDK.
Android will automatically position and manage your menu provided that you populate it in the activity.
If you've developed your application for Android 3.0 (API level 11) and higher, items from the options menu are available in the app bar. By default, the system places all items in the action overflow, which the user can reveal with the action overflow icon on the right side of the app bar (or by pressing the device Menu button, if available).
To enable quick access to important actions, you can promote a few items to appear in the app bar by adding android:showAsAction="ifRoom" to the corresponding <item> elements (see figure 2).
To add to a menu, see Activity.onCreateOptionsMenu

What is the difference between Context menu vs Popup menu vs bottom sheet?

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.

Menu button disappears when action bar is hidden in Kitkat

I'm developing an android app which doesn't have an action bar. I have the sign out and sync options as menu items. When I tried this in my Nexus 5, the menu button is nowhere to be found. It usually appears in the action bar. Is there a way to keep the menu button and hide the action bar at the same time?
Is there a way to keep the menu button and hide the action bar at the same time?
No. If you are not going to use the action bar, you cannot reliably use <menu> resources. Please put "sign out and sync options" in your own GUI, such as via buttons.
Note that the MENU key is itself deprecated now; few devices going forward will have one.

Android ICS Options menu with images

I am new to android.
How can i create option menu with out images like in the attached image? Do i need to use action bar or normal onCreateOptionMenu will do?
If you've developed your application for Android 3.0 (API level 11)
and higher, items from the options menu are available in the action
bar. By default, the system places all items in the action overflow,
which the user can reveal with the action overflow icon on the right
side of the action bar (or by pressing the device Menu button, if
available). To enable quick access to important actions, you can
promote a few items to appear in the action bar by adding
android:showAsAction="ifRoom" to the corresponding elements.
You can refer this doc for more detail.

Docked Settings Button override for Android

I am developing on a Galaxy Nexus, and I would like the settings icon on the main dock to open up some window of buttons. How do I go about handling this button press? it's that button that looks like a vertical "..."
That button:
will only appear on devices without a MENU button
will only appear if you have action bar items in the overflow menu
cannot be directly used for other purposes
You are welcome to have an action item in the action bar that will "open up some window of buttons". You can choose whatever icon you want for this action item. I strongly encourage you to not use the same icon as the action overflow menu. There are millions of possible icons, so surely you can choose one of greater relevance to whatever the "window of buttons" is and will not conflict with the users' expectations of what the action bar overflow should look and work like.

Categories

Resources