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
Related
If you've developed your application for Android 2.3.x (API level 10) or lower, the contents of your options menu appear at the bottom of the screen when the user presses the Menu button, as shown in figure 1. When opened, the first visible portion is the icon menu, which holds up to six menu items. If your menu includes more than six items, Android places the sixth item and the rest into the overflow menu, which the user can open by selecting More.
So adding a dynamic toolbar from appcompat-v7 will not dismiss the use of the menu button on the older phones?
I want to move the overflow button (that shows up the options menu) actually present in the top action bar to the bottom action bar. As actually done by Facebook application and many other applications. I want this for tablet only.
Screenshot:
Thanks.
First, neither of those screenshots show a "bottom action bar". They show the navigation bar.
Second, whatever is shown in your second screenshot is non-standard.
My guess is that second screenshot is supposed to be the legacy menu affordance. The objective of a modern Android app developer is to not show the legacy menu affordance, as it is an indication to users that your app is not being maintained. Modern Android apps have the overflow menu in the action bar (for devices without a dedicated MENU button).
That being said, if you wish to have fewer users, and therefore want to suggest to those users that your app is unmaintained, to have the legacy menu affordance, get rid of your action bar, such as by setting android:targetSdkVersion to 11 or lower.
You can read more about this in the documentation.
until now I compiled my app with SDK for Android 2.1. There the options/preferences button appeared automatically, I only had to bring it alive by providing methods onPrepareOptionsMenu() and onMenuItemSelected().
Now i switched over to SDK for 2.2 and my whole layout is...hm...damaged. Most obvious problem: the options-button is gone.
So what do I have to do to re-enable it for 2.2?
Thanks!
There the options/preferences button appeared automatically
There has never been an "options/preferences button" in Android that "appeared automatically". I am going to guess that you mean the legacy menu affordance in the system bar/navigation bar on Android 3.0 devices, for apps with android:minSdkVersion set too low.
So what do I have to do to re-enable it for 2.2?
The legacy menu affordance has nothing to do with your build target. It has everything to do with your android:minSdkVersion. More importantly, your objective should be to get rid of this affordance, as it is a sign to users that your app is out of date.
If you are using onPrepareOptionsMenu(), you should be using the action bar, in which case your former menu items will either appear in the action bar directly as toolbar-style buttons, or in the action bar's overflow menu ("..." button), or via a popup menu that appears when the user presses their device's MENU button.
If you do not want the action bar, then do not use onPrepareOptionsMenu(). Instead, create your own menu structure using your own widgets as part of your own activity UI.
You can read more about the action bar and the vanishing menu affordance in the documentation.
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.
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.