B4A Library Spotlight PopUp Menu

ilan

Expert
Licensed User
Longtime User

Just put the sp.show command in your button1_longclick event.
 

ziomorgan

Active Member
Licensed User
Longtime User
Hi,
i want change the button bitmap:

B4X:
Dim btn As Button = Spotlightmenu.ItemIcon(2)
btn.SetBackgroundImage(LoadBitmap(File.DirAssets, "no_notifica.jpg"))

but the image is not rounded as the initial one.
Is it a bug?

 

Mostez

Well-Known Member
Licensed User
Longtime User
first thanks for this great lib., sorry if it seems silly to ask, if I can remove the '=' sign appears at the right end of the menu item.
 

ilan

Expert
Licensed User
Longtime User
first thanks for this great lib., sorry if it seems silly to ask, if I can remove the '=' sign appears at the right end of the menu item.

yes you can. use the class instead of the lib. you can get the class from the source.zip. add it to you project.
now you need to update the "additem" function in the class to this:

B4X:
'Text = Set the Text of the Menuitem
'Text2 = Set the Text of the second Label (=)
'txtColor = Set the Textcolor
'txtsize = Set the Textsize
'bmp = set the icon bitmap
Public Sub additem(Text As String, Text2 as String, txtColor As Int, txtsize As Int, bmp As Bitmap)
   Dim dr As ColorDrawable
   dr.Initialize(Colors.White,(itemHeight/2)-1)

   Dim ItemPnl As Panel
   ItemPnl.Initialize("itempnl")
   ItemPnl.Tag = itemlist.Size
   ItemPnl.Background = dr

   Dim itemlbl As Label
   itemlbl.Initialize("itemlbl")
   itemlbl.Text = Text
   itemlbl.TextColor = txtColor
   itemlbl.Gravity = Gravity.CENTER_VERTICAL
   itemlbl.Typeface = Typeface.DEFAULT
   itemlbl.TextSize = txtsize

   Dim itemlbl2 As Label
   itemlbl2.Initialize("itemlbl2")
   itemlbl2.Text = Text2
   itemlbl2.TextColor = Colors.RGB(43,43,43)
   itemlbl2.TextSize = 24
   itemlbl2.Gravity = Gravity.CENTER
   itemlbl2.Typeface = Typeface.DEFAULT
   itemlbl2.Tag = "lbl"

   Dim itemimgbtn As Button
   itemimgbtn.Initialize("")
   itemimgbtn.Tag = "btn"
   itemimgbtn.Color = Colors.Transparent

   If bmp <> Null And bmp.IsInitialized Then
     itemimgbtn.SetBackgroundImage(updatebmp(bmp))
     itemimgbtn.Gravity = Gravity.FILL
   End If

  'add items to list
   ItemPnl.AddView(itemlbl,itemHeight+2%x,0,0,itemHeight)
   ItemPnl.AddView(itemimgbtn,itemHeight*0.1,itemHeight*0.1,itemHeight*0.8,itemHeight*0.8)
   ItemPnl.AddView(itemlbl2,0,0,itemHeight,itemHeight)
   itemlist.Add(ItemPnl)
End Sub

and now you can add an item like this:

B4X:
    Dim icon As Bitmap
    icon.Initialize(File.DirAssets,"images.png")

    splight.Initialize(Me,"splight",10%y,False,False,True,Button1,Activity)
    splight.additem("Inbox (5)", "#",Colors.Black,18,icon)
    splight.additem("Refresh","%",Colors.Black,18,Null)
    splight.additem("Compose","",Colors.Black,18,Null)

as you can see we are putting another string in our additem call. the second string is the "=" char you see in the menu.
if you dont want anything put an empty string like in the 3rd item.


### OPTIONAL ###
if you would like to update the second label in runtime add this function to the class:

B4X:
'Get the Label2 of the Menuitem
Public Sub ItemLabel2(index As Int) As Label
    If itemlist.Size-1 < index Then
         Log("Index is wrong.")
         Return Null
    End If
    Dim p As Panel = itemlist.Get(index)
    Dim lbl As Label = p.GetView(2)
    Return lbl
End Sub

and you can can update the second label text like this:

B4X:
Sub splight_Click(index As Int)
    Log("selected itemindex: " & index)
    'UPDATE AN ITEM !!!
    splight.ItemLabel2(index).Text = "$"
End Sub
 

ibra939

Active Member
Licensed User
Longtime User
THANKS SO MUCH
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…