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: 846
  • ICSPopup.zip
    8.2 KB · Views: 730
  • Untitled.png
    Untitled.png
    17.5 KB · Views: 2,119
  • res.zip
    65 KB · Views: 736
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
Looks better for the separators, well done!


:sign0008:Congrats on post 1000:wav:Maybe I will get there one day...
 

susu

Well-Known Member
Licensed User
Longtime User
Very nice menu! Thank you so much.
 

Ian Garton

Member
Licensed User
Longtime User
Not sure what I'm doing wrong here, but I can't get the sample to work.
I've copied the AHQuickAction resources, made them Read Only, but continue to get a Resource not found error.

As soon as I change --
Dim q As ICSMenuPopup
to
Dim q As AHQuickAction3D

and change --
q.Initialize("AC")
to
q.Initialize("AC",1)

it works correctly as an AHQuickAction menu.

Zipped project attached.

Thanks


B4X:
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.maximus.icsmenusample
** Activity (main) Create, isFirst = true **
main_activity_create (B4A line: 31)
q.Initialize("AC")
android.content.res.Resources$NotFoundException: Resource ID #0x0
   at android.content.res.Resources.getValue(Resources.java:1019)
   at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
   at android.content.res.Resources.getLayout(Resources.java:858)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
   at com.maximus.quickpopup.quickpopup.setRootViewId(quickpopup.java:107)
   at com.maximus.quickpopup.quickpopup.Initialize(quickpopup.java:74)
   at com.maximus.icsmenusample.main._activity_create(main.java:347)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:136)
   at com.maximus.icsmenusample.main.afterFirstLayout(main.java:84)
   at com.maximus.icsmenusample.main.access$100(main.java:16)
   at com.maximus.icsmenusample.main$WaitForLayout.run(main.java:72)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4340)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
android.content.res.Resources$NotFoundException: Resource ID #0x0
 

Attachments

  • ICSMenuSample_1.zip
    77.8 KB · Views: 254

thedesolatesoul

Expert
Licensed User
Longtime User
Thanks Ian for testing and providing a good report back.

I can see what is going wrong. For some reason, when I exported my sample project to zip, it has not copied over all the directories under 'res'. There are a few xml layout files missing.

I will add those when I get home, and hopefully it will work.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Selected item color in menu

Hi,

I was wondering if the orange color when selecting an item is the correct color? If not, can it be set somewhere?

Cheers,
 

thedesolatesoul

Expert
Licensed User
Longtime User
Hi,

I was wondering if the orange color when selecting an item is the correct color? If not, can it be set somewhere?

Cheers,

Honestly, I dont own any ICS hardware so I do not know what the correct color is. I got it from the ICS related resources in sdk14.
The drawable is the ics_action_item_selected.9.png in Objects\res\drawable in your B4A project. You can change it, it is fairly easy, just replace it with another similar 9patch image.
Similarly you can also change the background by changing ics_popup.9.png
Let me know if you have any more questions. You may want to read Erel's 9patch tutorial.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Integration of new menu style worked

Hi,

Attached a screenshot of your improved ICS menu in my search nearby app., great!
 

Attachments

  • Screenshot_2012-04-26-14-20-33.png
    Screenshot_2012-04-26-14-20-33.png
    57.5 KB · Views: 480

Amalkotey

Active Member
Licensed User
Longtime User
ICSMenuSample Runtime Error

@TheDesolateSoul:

Unfortunately, always following error message get displayed, although the RES folder in the object folder was copied. I'm testing it on my HTC desire Classic under Android 2.2.1. is it out?

Thank you for your help in advance.

Best wishes

-Amalkotey-
 

Attachments

  • ICSMenuSample Runtime-Error.png
    ICSMenuSample Runtime-Error.png
    54.2 KB · Views: 252
Top