Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

enter image description here

More information on how to implement it is available here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top