Android Question RSPopupMenu & IconPicker?

ilan

Expert
Licensed User
Longtime User
hi

i am trying to add an icon to a string on my RSPopup Menu.

but the icon is not shown instead i see a rectangle with a cross in it.

code:

B4X:
    PopupMenu.Initialize("PopupMenu", newshiftadd)
    PopupMenu.AddMenuItem(0, 0, Chr(0xF271) & "   משמרת חדשה")
    PopupMenu.AddMenuItem(1, 1, Chr(0xF20B)  & "   תשלום קבוע")

result:

Screenshot_2017-01-05-12-06-21.png


is it not possible to use icons with strings?
 

Haris Hafeez

Active Member
Licensed User
Longtime User
Looks like you need to get the label used by the popup menu and set its typeface. Not sure how to do it though unfortunately.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
there is no such settings in popupmenu :(
to bad...

- Try to contact the author to get the source of the lib and i´ll adapt it for you
- Try to find a java library on Github which does what you you need and post a thread in wish-forum for it. Maybe someone will do a wrap :D

As xverhelst is no longer active i would suggest the second. Find a java lib on Github which does what you need and post a wish or a joboffer
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

ilan

Expert
Licensed User
Longtime User
mPopup.setForceShowIcon(true);//ADD THIS LINE

You need access to the libs source i guess to add it

i have tried it already like this but it didnot work.

B4X:
   Dim jo As JavaObject = ppm
   jo.GetFieldJO("mPopup").RunMethod("setForceShowIcon",Array(True))

maybe you are right, maybe its a different PopUp Menu.

is there a function to get all fields in a JO?

like an array of all available fields, like this i could try to get the view via reflector and set the label typeface to fontawesome.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Step 1: Use RichString v1.5 https://www.b4x.com/android/forum/threads/richstring-library.10680/#post-59476

Step 2: Add a Label named lblFontAwesome with the designer and set its Typeface to FontAwesome (you can make it invisible).

Step 3: Use this code to add items:
B4X:
AddMenuItem(PopupMenu, 0, 0, Chr(0xF271) & "  משמרת חדשה")

Private Sub AddMenuItem (PM As RSPopupMenu, ItemId As Int, Order As Int, Title As String)
   Dim jo As JavaObject = PM
   Dim menu As JavaObject = jo.RunMethodJO("getMenu", Null)
   menu.RunMethod("add", Array(0, ItemId, Order, CreateFAString(Title)))
End Sub

Private Sub CreateFAString(s As String) As RichString
   Dim rs As RichString
   rs.Initialize(s)
   rs.TypefaceCustom(lblFontAwesome.Typeface, 0, rs.Length)
   Return rs
End Sub

BTW, the reason that we cannot use the library method to add the items is that the library accepts a String instead of a CharSequence. So we need to call the native API directly.
 
Upvote 0
Top