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.
Think of the option menu as a global menu, that's activated when the MENU button is pressed in an Activity. Think of the context menu as a right-click-menu on a component; just press and hold (with the enter key on the emulator D-Pad) and this context menu will get activated.
The contextual action 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. See the section about Creating Contextual Menus. A popup menu displays a list of items in a vertical list that's anchored to the view that invoked the menu.
Android Option Menus are the primary menus of android. They can be used for settings, search, delete item etc. When and how this item should appear as an action item in the app bar is decided by the Show Action attribute.
There are three types of menus in Android: Popup, Contextual and Options. Each one has a specific use case and code that goes along with it.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With