B4A Library ICSMenuPopup

Okay, for my 1000th post I wanted to post something special. This isnt that great, but hey.

You can create a menu similar to ICS Overflow menu with this library.
I havent exhaustively tested it, just tested it for the one case I have used in the sample below.

Requirements:
This library requires AHQuickActions to be added to the B4A project.
It also requires several xml files and image files to be in your res folder as read-only.

How it works:
It extends the PopupWindow class which is a really useful class for non-modal but obtrusive controls.
I modified one of corwin42's AHQuickActions vertical menu. Removed the arrows, added separators. Edited the xml files to give it a menu look. Added and edited the ICS drawables. This is a fairly hacky piece of work as a proof-of-concept.

Having problems:
Make sure you get AHQuickActions to work before embarking on this one. This is similar but with extra xml and png files (The ics_*).

Credits:
Original libraries:
NewQuickAction
NewQuickAction3D
corwin42's libraries: AHQuickAction Library
Erel's 9patch tutorial: Nine Patch Tutorial
COBRASoft for helping me with 9patch stuff
The usual bunch: NJDude, Barx, XverhelstX and my parents.
 

Attachments

  • ICSMenuPopup.zip
    26.5 KB · Views: 921
  • ICSPopup.zip
    8.2 KB · Views: 815
  • Untitled.png
    Untitled.png
    17.5 KB · Views: 2,194
  • res.zip
    65 KB · Views: 839
Last edited:

Amalkotey

Active Member
Licensed User
Longtime User
Amalkotey,
1. Are all the files in 'res' set to read-only?
2. Did you do Clean Project, and then re-compiled?
3. If the above two do not solve your problem, you can post your project with File>Export to Zip.
Thanks.

@TheDesolatesoul: Thank you for your help. After implementation of the above measures, the program has worked. Super work. Thanks for the release.

-Amalkotey-
 

Inman

Well-Known Member
Licensed User
Longtime User
Ever since you introduced this library I have been using it in almost all my projects as it matches with the dark color scheme of my app. But my new project has a white background. Will it be possible for you to provide the res files for the light version of the ICS menu (as in Holo Light theme)?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Ever since you introduced this library I have been using it in almost all my projects as it matches with the dark color scheme of my app. But my new project has a white background. Will it be possible for you to provide the res files for the light version of the ICS menu (as in Holo Light theme)?

There is one file called res\drawable\ics_popup.9.png and another called res\drawable\ics_action_item_selected.9.png (you dont have to change this one)

You need to replace the first file with the file here (from your Android SDK path):
F:\Program Files (x86)\Android\android-sdk\platforms\android-14\data\res\drawable-hdpi\menu_dropdown_panel_holo_light.9.png

Rename and rewrite over the old file and set it to Read-only.
Then clean project, and compile.

BTW, both the menus look better if you have a light background as you can see the shadow as well, but its not visible in a dark background.
 

Inman

Well-Known Member
Licensed User
Longtime User
Thanks man. I also had to change textcolor to black in Objects\res\layout\ics_action_item_vertical.xml file as white on white was not visible.

I never noticed the shadow until you said. Looks nice.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Thanks man. I also had to change textcolor to black in Objects\res\layout\ics_action_item_vertical.xml file as white on white was not visible.

I never noticed the shadow until you said. Looks nice.
Oops. Yes I forgot that. Good that you found it.
Will be cool to see some of your apps in action :)
 

Dave O

Well-Known Member
Licensed User
Longtime User
I did the changes above to get the popupmenu working in Holo Light. Looks good in my app.

However, setting an actionItem to Selected doesn't cause any visual change in the menu. Is there another tweak I need to make to the PNG files or the XML?
 

thedesolatesoul

Expert
Licensed User
Longtime User
I did the changes above to get the popupmenu working in Holo Light. Looks good in my app.
Can we see a screenshot? :)

However, setting an actionItem to Selected doesn't cause any visual change in the menu. Is there another tweak I need to make to the PNG files or the XML?
Did you change the ics_action_item_selected.9.png file?
 

Dave O

Well-Known Member
Licensed User
Longtime User
Will post a screenshot in a few days once I have real icons in place. The menu is currently the best-looking part. :^)

ics_action_item_selected.9.png - I assume you mean the "ahqa_action_item_selected.9.png" file. I haven't touched that one, and it looks correct (orange gradient fill).

When I show the menu and tap a menu item, it highlights orange, so that works. But if I select an item's Selected property to true, it doesn't appear selected when showing the menu. Is that what it should do?

Also, is there a way to group menu items (i.e. using separators or perhaps blank items that aren't selectable themselves)?

Thanks!
 

thedesolatesoul

Expert
Licensed User
Longtime User
ics_action_item_selected.9.png - I assume you mean the "ahqa_action_item_selected.9.png" file. I haven't touched that one, and it looks correct (orange gradient fill).
No, I meant the file I said.

When I show the menu and tap a menu item, it highlights orange, so that works. But if I select an item's Selected property to true, it doesn't appear selected when showing the menu. Is that what it should do?
Unfortunately it doesnt use the selected property at all. Neither does AHQuickActions (on which this is based). I am not sure if it is supposed to work that way.

Also, is there a way to group menu items (i.e. using separators or perhaps blank items that aren't selectable themselves)?
I never thought about this. I havent quite seen this behaviour in android apps where there is less screen estate available. I cant think of a way to do this with the current lib.
 

apty

Active Member
Licensed User
Longtime User
i am trying to use this but when i click on any of the menu item, nothing happens. What could be the problem?
 

apty

Active Member
Licensed User
Longtime User
i just used the sample without changing anything but clicking menu item doesnt do anything
 

little3399

Active Member
Licensed User
Longtime User
Hi, thedesolatesoul
1. how to know which ActionItem was select in the popmenu ? because I can not find any "AC" event handle code in the ICSMenuPopup.zip ?

2. how to change the background color for the popmenu ?

Could you tell me about these ? TKS!
 

thedesolatesoul

Expert
Licensed User
Longtime User
Just to let you know the AHQuickAction library already integrates this library into it, so you may not need it.
1. I cant remember the exact specifics, but there is an event that is raised that gives you which item is clicked. Something in the form of:
B4X:
Sub AC_Click (Position AsInt, ActionItemID AsInt)
2. You will have to edit the xml files in Object/res
 

little3399

Active Member
Licensed User
Longtime User
Hi,Could you tell me if I want to change the background color for the popmenu, which file must be to edit ? TKS!
 

thedesolatesoul

Expert
Licensed User
Longtime User

arnold steger

Member
Licensed User
Longtime User
It`s posible to maked 2 ICSMenuPopup.
I have a Popup menu for example whit tracking, position...
when click tracking i whant open an other pupup menu whit tracking start, tracking stop, show tracking...
 
Top