B4A Library StdActionBarHelper - Utilities for the Standard ActionBar

ttsolution

Member
Licensed User
Longtime User
Hi all,

I have a listview, I want to show a popup menu when ListView Item clicked. How to achieve that ?

Many thanks

Jonh,
 

ttsolution

Member
Licensed User
Longtime User
Sorry, I'm not sure but my question is related to StdActionBarHelper

B4X:
Dim pop As PopupMenu
pop.Initialize("ListPopup", ButtonAction)    
pop.AddMenuItem(1, "Sales Order", GetDrawable("ic_menu_login"))
pop.AddMenuItem(2, "Take Picture", GetDrawable("ic_action_edit"))
pop.Show

When the ButtonAction is clicked the PopupMenu will be show next to the ButtonAction's anchor.

My question is: I have a listview of Customers and I want to show a PopupMenu right at the line that user tabed, because the second parameter of pop.Initialize("ListPopup", ButtonAction) requires a view. If I code pop.Initialize("ListPopup", myListView) then the PopupMenu always show at the top of myListView.

Appreciate for any help

Jonh,
 

corwin42

Expert
Licensed User
Longtime User

In this post you will find a solution to get the view at the ListViews current position. It is old but it still should work.
 

corwin42

Expert
Licensed User
Longtime User
@corwin42
is this library working just on android +3?

Since it uses the standard ActionBar which is only available from Android 3.x: Yes, it works only on Android 3+
 

iglrs1

Member
Licensed User
Longtime User
Hi,

I have tried to test the NavDrawerStdActionBarExample with the additional libs needed but when I copile it I get the following error:

B4A version: 5.20
Parsing code. (0.01s)
Compiling code. (0.03s)
Compiling layouts code. (0.03s)
Generating R file. (0.33s)
Compiling generated Java code. Error
Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\nineoldandroid-2.4.0.jar

I have downloaded and copy the nineoldandroid-2.4.0.jar file but still same error. Any help?

Thx
 

corwin42

Expert
Licensed User
Longtime User

Sorry, there was a typo in the AHNavigationDrawer library. Either update to version 1.40 of the library or rename your nineoldandroids-2.4.0.jar to nineoldandroid-2.4.0.jar (without the s). Better update the library.
 

Kwame Twum

Active Member
Licensed User
Longtime User

Please I tried doing this @corwin42 and everyone, but my app still shows the same old colors..
• Created my theme
• Downloaded it and copied it to my objects\res folder
• Made them all read only
• Set theme in the manifest editor

Currently running Android 5.0. Kindly help out.
 

corwin42

Expert
Licensed User
Longtime User

Which target SDK version do you set in the manifest?

Do you have an example project?
 

Kwame Twum

Active Member
Licensed User
Longtime User
Which target SDK version do you set in the manifest?
Target SDK is 19, I tried 22 and didn't work either.

The project is attached...
 

Attachments

  • ThemeTest.zip
    60.3 KB · Views: 354
Last edited:

Dave O

Well-Known Member
Licensed User
Longtime User
Hi @corwin42

I use PopupMenu in some of my apps, and it generally works great.

However, I just tried to disable a menu item for the first time, and I'm having trouble getting GetItem to work.

Here's the code:
B4X:
dim const PREVIOUS_PAGE as int = 1001
dim const ANOTHER_PROTO as int = 1002

Dim linkMenu As PopupMenu
linkMenu.Initialize("linkMenu", pendingLinkPanel)
Dim bmd As BitmapDrawable
 
bmd.Initialize(LoadBitmap(File.DirAssets, "back32.png"))
linkMenu.AddMenuItem(PREVIOUS_PAGE, "Previous Page", bmd)   'so far, so good

bmd.Initialize(LoadBitmap(File.DirAssets, "another-proto32.png"))
linkMenu.AddMenuItem(ANOTHER_PROTO, "Another Prototype...", bmd)
If common.protoList.Size < 2 Then     'no other prototype to link to
  Dim tempItem As MenuItem = linkMenu.GetItem(ANOTHER_PROTO)
  tempItem.Enabled = False
End If

When it tries to do the GetItem, I get an "index out of bounds" exception on the ItemID. It looks like GetItem is trying to treat ItemID as an index to an array, rather than as a unique ID:

B4X:
java.lang.IndexOutOfBoundsException: Invalid index 1009, size is 2
   at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
   at java.util.ArrayList.get(ArrayList.java:308)
   at com.android.internal.view.menu.MenuBuilder.getItem(MenuBuilder.java:656)
   at de.amberhome.actionbarhelper.PopupMenuWrapper.GetItem(PopupMenuWrapper.java:102)
   ...

Bug? Or am I missing something here?

Thanks!
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
Weird!

I am using your "ACPopupMenu" to display a pop up menu, but the menu is sometimes randomly popping up in a different location even though I am specifying the SAME/fixed view during initialization:

B4X:
    Pop.Initialize("Popup",  pnlInv)

Any idea why this is happening?
 

corwin42

Expert
Licensed User
Longtime User
No. No such issue is known.

Create an example project which shows this error and post it in the correct thread (for ACPopupMenu use the AppCompat library thread).
 

cxbs

Active Member
Licensed User
Longtime User
Dear Mr. Corwin 42

Thank you for providing such a concise and easy-to-use StdActionBarHelper library.
Can I remove the displayed log information when adding icons?
Thanks again!

The following is the log information:
Set Icon
Set Icons visible
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…