AHActionBar Library

corwin42

Expert
Licensed User
Longtime User

yttrium

Active Member
Licensed User
Longtime User

Richard Goh

Active Member
Licensed User
Longtime User
Hi. I was trying to integrate the AHQuickAction function in my test program by using the Activity.AddMenuItem3() item instead of using button. When I clicked on the menuitem, the program hit the below error. My program was added a CustomListView by using Activity.AddView(CustomListView, x,x,x)

main_menu_click (B4A line: 296)
ac1.show(Sender)
java.lang.ClassCastException: java.lang.String cannot be cast to android.view.View
at b4a.test.main._menu_click(main.java:1033)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at b4a.test.main$B4AMenuItemsClickListener.onMenuItemClick(main.java:142)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:144)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:603)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:163)
at android.view.View.performClick(View.java:4262)
at android.view.View$PerformClick.run(View.java:17351)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4935)
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:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
 

corwin42

Expert
Licensed User
Longtime User
If you click a menu item then the sender is not a view but a simple string (The Menu text).

You have to place a dummy view (panel) somewhere on the screen and use this as an anchor object for the QuickAction.
 

Richard Goh

Active Member
Licensed User
Longtime User
Hi Corwin,
thanks for your reply. I had tested with button and it's working. But can't when using MenuItem on Activity title, added using Activity.AddMenuItem3() function. Is there any refererences or sample code I can refer to?
thanks.
 
Last edited:

Dario126

Member
Licensed User
Longtime User
Why this code works ok in debug mode, and not in relase?

B4X:
'Part from Sub Global:

    Dim AB As ClsActionBar
    Dim PopupMenu1 As AHPopupMenu
    Dim PopupPatrolType As AHQuickAction3D


'Part from Activity_create:

    PopupMenu1.Initialize("PopupMenu1")
    AddAHActionMenuItem(PopupMenu1, 1, "STOP", "Icon Stop.png", False)    'THIS IS WHERE IT STOPS WITH ERROR
    AddAHActionMenuItem(PopupMenu1, 2, "Settings", "Icon Settings.png", False)
    AddAHActionMenuItem(PopupMenu1, 3, "About App & OS MAPS", "Icon About.png", False)


'Custom Sub to add items

Sub AddAHActionMenuItem(MenuObject As View, ItemIndex As Int, Text As String, IconFileName As String, Sticky As Boolean)

    Dim ai As AHActionItem
    Dim Icon As BitmapDrawable
    Icon.Initialize(LoadBitmap(File.DirAssets, IconFileName))

    ai.Initialize(ItemIndex, Text, Icon)

    If Sticky Then ai.Sticky = True

    'Add the item to menu
    Dim obj As AHQuickAction
    obj=MenuObject
    obj.AddActionItem(ai)

End Sub


I get this error:

B4A line: 127
AddAHActionMenuItem(PopupMenu1, 1, \
javac 1.7.0_10
src\com\omgpolice\main.java:386: error: inconvertible types
_addahactionmenuitem((anywheresoftware.b4a.objects.ConcreteViewWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.ConcreteViewWrapper(), (android.view.View)(mostCurrent._popupmenu1)),(int) (1),"Project1","Icon Stop.png",anywheresoftware.b4a.keywords.Common.False);
^
required: View
found: ICSMenu


Where is mistake?


I was trying to make sub to easily add new items. Why this is not implemented or I'm missing it?
 
Last edited:

chrjak

Active Member
Licensed User
Longtime User
I tried your introduction 3 times and always i get this:
B4X:
res\values\ahab_colors.xml:17: error: Resource at actionbar_divider appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:18: error: Resource at actionbar_title appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:19: error: Resource at actionbar_subtitle appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:20: error: Resource at actionbar_background_start appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:21: error: Resource at actionbar_background_end appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:22: error: Resource at actionbar_background_dropdown_start appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:23: error: Resource at actionbar_background_dropdown_end appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:24: error: Resource at actionbar_background_item_pressed_start appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:25: error: Resource at actionbar_background_item_pressed_end appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_colors.xml:26: error: Resource at actionbar_tab_bar_background appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_dimens.xml:17: error: Resource at actionbar_height appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_dimens.xml:18: error: Resource at actionbar_item_height appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_dimens.xml:19: error: Resource at actionbar_item_width appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahab_ids.xml:4: error: Resource at actionbar_item_home appears in overlay but not in the base package; use <add-resource> to add.
res\layout\ahab_actionbar.xml:16: error: Error: No resource found that matches the given name (at 'layout_height' with value '@dimen/actionbar_height').
res\layout\ahab_actionbar.xml:49: error: Error: No resource found that matches the given name (at 'background' with value '@color/actionbar_divider').
res\layout\ahab_actionbar.xml:72: error: Error: No resource found that matches the given name (at 'background' with value '@color/actionbar_divider').
res\layout\ahab_actionbar.xml:102: error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_title').
res\layout\ahab_actionbar.xml:121: error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_subtitle').
res\layout\ahab_actionbar.xml:172: error: Error: No resource found that matches the given name (at 'background' with value '@color/actionbar_tab_bar_background').
res\layout\ahab_item.xml:16: error: Error: No resource found that matches the given name (at 'layout_width' with value '@dimen/actionbar_item_width').
res\layout\ahab_item_home.xml:16: error: Error: No resource found that matches the given name (at 'layout_width' with value '@dimen/actionbar_item_width').
res\layout\ahab_list_dropdown_item.xml:3: error: Error: No resource found that matches the given name (at 'layout_height' with value '@dimen/actionbar_height').
res\layout\ahab_list_dropdown_item.xml:3: error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_title').
res\layout\ahab_tab.xml:35: error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_title').
res\layout\ahab_title.xml:3: error: Error: No resource found that matches the given name (at 'layout_height' with value '@dimen/actionbar_height').
res\layout\ahab_title.xml:3: error: Error: No resource found that matches the given name (at 'textColor' with value '@color/actionbar_title').
res\drawable\ahab_background.xml:18: error: Error: No resource found that matches the given name (at 'startColor' with value '@color/actionbar_background_start').
res\drawable\ahab_background.xml:18: error: Error: No resource found that matches the given name (at 'endColor' with value '@color/actionbar_background_end').
res\drawable\ahab_background_dropdown.xml:18: error: Error: No resource found that matches the given name (at 'startColor' with value '@color/actionbar_background_dropdown_start').
res\drawable\ahab_background_dropdown.xml:18: error: Error: No resource found that matches the given name (at 'endColor' with value '@color/actionbar_background_dropdown_end').
res\drawable\ahab_btn_normal.xml:18: error: Error: No resource found that matches the given name (at 'startColor' with value '@color/actionbar_background_start').
res\drawable\ahab_btn_normal.xml:18: error: Error: No resource found that matches the given name (at 'endColor' with value '@color/actionbar_background_end').
res\drawable\ahab_btn_pressed.xml:18: error: Error: No resource found that matches the given name (at 'startColor' with value '@color/actionbar_background_item_pressed_start').
res\drawable\ahab_btn_pressed.xml:18: error: Error: No resource found that matches the given name (at 'endColor' with value '@color/actionbar_background_item_pressed_end').

Edit: Wie ich gerade sehe bist du aus Deutschland :)
Also ich hab alles gemacht, wie du gesagt hast aber bei "Generating R File" kommt immer das da oben. Ich konnte allerdings schon einmal deine Actionbar erfolgreich nutzen. Jetzt gehts egal, was ich mache in meinem neuen Projekt nicht mehr!?
Grüße
P.S. Gute Arbeit!
Edit: works now. It was a b4a v. 3.2 bug. Erel- please solve this :)
 
Last edited:

corwin42

Expert
Licensed User
Longtime User
Edit: Wie ich gerade sehe bist du aus Deutschland :)
Also ich hab alles gemacht, wie du gesagt hast aber bei "Generating R File" kommt immer das da oben. Ich konnte allerdings schon einmal deine Actionbar erfolgreich nutzen. Jetzt gehts egal, was ich mache in meinem neuen Projekt nicht mehr!?
Grüße
P.S. Gute Arbeit!
Edit: works now. It was a b4a v. 3.2 bug. Erel- please solve this :)

Yes, it's a problem with the 3.20 version of B4A if you use the #AdditionalRes attribute. Will be solved in B4A 3.50.
 

little3399

Active Member
Licensed User
Longtime User
Hi,
Does the AhActionbar Lib can be implemented the drop-down menu , such as like this , TKS

upload_2014-6-23_15-38-44.png
 

corwin42

Expert
Licensed User
Longtime User
Hi,
Does the AhActionbar Lib can be implemented the drop-down menu , such as like this , TKS

View attachment 25847

You can use AHQuickaction library for adding a PopupMenu style menu like the above.

I currently recommend to use StdActionBar library if possible. There you will have the overflow menu feature automatically included.
 
Top