I want to create custom options menu as below and also want this to be available on all activities.
So far I am able to add options menu using onCreateOptionsMenu method, and setting its icons.
But have no idea how it can be inflated as shown in images.
After doing some google search found out one example . If can get more help on implementing custom options menu.
Neither of those are options menus. If they happen to be triggered by pressing a MENU button, then those apps are monitoring onKeyDown() for MENU button presses. This also means that their menus will not work on devices that lack such a MENU button.
I strongly encourage you to follow the Android design guidelines. I recommend that you start integrating an action bar and using action items and the action overflow area, perhaps leveraging ActionBarSherlock to support Android 2.x devices.
Related
I need to open android support library action bar overflow menu (the one shown with three vertical dots) programatically. I know its a silly requirement but one of my client is insisting that they want the menu option to be opened and visible when user tap on a button in an activity.
Any pointer on how to do this will be highly appreciated.
Try using openOptionsMenu in your Activity.
You can do something similar to this implementing your own custom ActionProvider Check this out, in the "Creating a custom action provider" section.
Hope it helps
When in some apps, there are those 3 dots in the top right of the app, on the action bar (not the home buttons), which allow for more options. In my app I have on, but I do not know how to make it do a method when it is clicked. Do I use android:onClick="METHOD_NAME ? Or do I need to setup a button variable in my activity class and setup and onClickListener? I have already tried both but I may be doing something wrong.
That three dots are the menu in the action bar. They are always shown on devices without a menu key.
See also the documentation for more details.
Three dots are called Overflow(very aptly named) and to use them you need to use ActionBar which is the top long, horizontal bar showing icons, other buttons along with the Overflow button.
Now in some devices where there is no physical menu button you will always see Overflow button.
Go through Docs and tutorials related to ActionBar but keep one thing in mind that ActionBar is only available for devices with android above HoneyComb. For android devices below 3.0 such as GingerBread or Froyo you will have to use compatibility libraries, so that will be an additional task.
And most notable libraries for this purpose are ActionBarSherlock and AppCompat.
I want to implement this kind of "pop up menu" in my app but I have no idea how it is called and therefore I can't do any research on how to do it.
This is the picture
I want this menu to have three options, right now I'm using AlertDialog and the buttons are right next to each other (positive, negative, neutral), but I'd rather use this kind of pop up menu since it can have more buttons and looks more professional.
I'm not asking for the code or anything, I just want to know how this menu is called so that I can do my research then.
What you are looking for is a Context Menu. There are two options, a floating context menu (like the one on your image), or the contextual action mode (shows the options on an ActionBar, like the GMail app for example).
You can choose which one is more appropriate for your app, but the official documentation states:
If you're developing for Android 3.0 (API level 11) or higher, you
should usually use the contextual action mode to present contextual
actions, instead of the floating context menu.
User Marcelo gave me an answer.
This is what I was looking for
I am trying to find a way to impelement a share button into my app (same like the one in the standard ICS gallary app, see picture link).
http://betanews.com/2011/10/19/get-acquainted-with-the-newest-android-ice-cream-sandwich-slideshow/#11
Intent.ACTION_SEND only opens a dialoge to the select the sharing options.
Android Share Via Dialog
This works fine, but from design side, I find this drop down list to select a app much more convenient.
Yet I cant figure out how to?
Does anybody have a good Idea how this button could be coded?
That is implemented using a ListPopupWindow, which at the moment is only available on Android 4.0.
This is implemented using ShareActionProvider available in SDK14+.
ActionProvider class replaces an action item with a customized layout,
but it also takes control of all the item's behaviors. When you
declare an action provider for a menu item in the action bar, it not
only controls the appearance of the item in the action bar with a
custom layout, but also handles the default event for the menu item
when it appears in the overflow menu
Its quiet easy to implement, you can follow the official documentation here.
I'd like to create a navigation menu in my Android app: a bar always at the bottom of the screen, with 4 choices Home|Categories|Search|Favorites, and the current page highlighted.
It seems the options menu can hardly be customized, so I can't use it.
Do I have to add this navigation bar in every layout or is there any better solutions?
Thanks
Julien
It sounds like you're replicating an iPhone interface. As most Android phones have buttons along the bottom of the screen (Home, Back, etc) it's likely to be a bad idea to put navigation there as it's easy to hit the wrong one.
The Google-recommended approach is to use the Action Bar pattern, across the top of the screen, which is very clear, and means your app is consistent with others (look at Twitter, Google Maps, Facebook - they all use the action bar pattern).
From Honeycomb (v3.0) onwards:
http://developer.android.com/reference/android/app/ActionBar.html
A simple library to create an Action Bar on any version of Android
https://github.com/johannilsson/android-actionbar
To create an action bar that uses that library on versions earlier than 3.0, but uses the official implemention for v3.0+, try this:
https://github.com/JakeWharton/ActionBarSherlock
The action bar is highly customisable, but remember that a key to a nice user interface is consistency across the platform, i.e. your app consistent with other apps and the OS.
If you need a navigation with more items or items within a specific page, you can use TabLayout, but for your primary nav, use the action bar, that's what it's for.
Use the TabLayout