Popup menu in Android 1.5 - android

I need something that looks like a popup menu in Android 1.5 that I can trigger from a button press.
(the version number is a hard limit, by the way)
According to the documentation, an ordinary popup menu is supported, but only in Android 3.x and higher.
I'd prefer to do it without adding another Activity, but can if that's the best option.
I already have the menu defined in XML, I just need to figure out how to make it display.

I think you are looking for a Dialog. I recommend you to use AlertDialog, as it is easier to use through its Builder class. You will be able to use your custom XML to define the layout for the Dialog.
It is available since API level 1, so you would not have problems. Here you have doc info AlertDialog

If you want that pop up menu to display more options, I suggest using the QuickAction. It is not available in Android SDK so you're gonna have to build it manually
//Add action item
ActionItem addAction = new ActionItem();
addAction.setTitle("Add");
addAction.setIcon(getResources().getDrawable(R.drawable.ic_add));
//Accept action item
ActionItem accAction = new ActionItem();
accAction.setTitle("Accept");
accAction.setIcon(getResources().getDrawable(R.drawable.ic_accept));
//Upload action item
ActionItem upAction = new ActionItem();
upAction.setTitle("Upload");
upAction.setIcon(getResources().getDrawable(R.drawable.ic_up));
Looks like this
More information on how to implement it is available here

Related

How is this "menu" called?

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

How to Override WL.OptionsMenu.addItem?

Working on Worklight project for Android platform. Wondering is there any way to override WL.OptionsMenu.addItem?
This is not to hide settings option menu. From Android SDK 11, option menu will be replaced with action bar. In full screen of WebView there is no way to show action bar. In this mobile app, implemented sliding menu. Each time invoke WL.OptionsMenu.addItem will add a menu item in sliding menu.
Thanks
Based on your edit:
Worklight does not yet support the ActionBar in Android, so oddities can happen when using the WL.OptionsMenu API in conjunction with API Level 11 in Android.
Can you explain what you're trying to accomplish? What does "overriding" an item mean in your case?
This is the WL.OptionsMenu API, you can do whatever you want in its limits.
If you mean that you'd like to simply remove the default "Worklight Settings" item, then you need to set worklightSettings to 'false' in application-descriptor.xml. After that, you can simply initialize the OptionsMenu and add any items you need to it.
If you mean that you have an existing item you would like to change, since you know the item ID, you can simply re-create the item, which essentially overrides what it was previously doing.

Custom options menu using custom theme and options

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.

Use share button (like in ICS gallary) instead of share dialoge (Intent.ACTION_SEND)

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.

How to create a custom Pulldown in the Honeycomb ActionBar?

I would like to add a custom pulldown menu to the actionbar in my project similar to the one that can be found in the google books app (screen).
In this case it represents the complete table of contents of the book.
I tried to follow the guide from the developer site where there is an example with a SpinnerAdapter. But when i use a custom Layout (in my case a RelativeLayout with two TextViews in it) i get an Exception that saying "ArrayAdapter requires the resource ID to be a TextView". So i dismissed my idea with the pulldown but then i found the pulldown in the books app wich looks to me like they used a custom layout as well because it looks to me like two single TextViews in one Layout.
Could anybody please enlighten me if what i want to do is even possible and how?
To me, that looks like the options menu -- that's where options menu items not promoted to the action bar itself appear. Use onCreateOptionsMenu() and add whatever items you want to the Menu.
EDIT:
Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:
This could be a submenu for that action bar item -- I haven't played with submenus and the action bar yet (though this reminds me that I need to do that...)
This could be a PopupMenu tied to a custom action bar View

Categories

Resources