iOS Question add ToolbarButtons ... bug or me bug :-)

ivanomonti

Expert
Licensed User
Longtime User
Result null

B4X:
    NavControl = Nav
    NavControl.NavigationBarVisible = True
    NavControl.ToolBarVisible = True
    Page1.Initialize("Page1")
    Page1.Title = "Job2Go v2"
    Page1.RootPanel.Color = Colors.Black
    NavControl.ShowPage(Page1)


    Dim lis As List
    lis.Initialize
    lis.add("Profilo")
    lis.add("Leggimi")
    lis.add("Annuncio")
'    Dim nbb As NavButtomBottom
'    nbb.Initialize(Page1,"nbb",lis)
    '
    For i = 0 To lis.Size-1
        addToolbarButtons(lis.Get(i))
    Next


B4X:
Sub addToolbarButtons(title As String)
    Dim b As BarButton
    b.InitializeText(title,title)
    b.Enabled = True
    Page1.ToolbarButtons.Add(b)
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the documentation:
SS-2014-11-14_11.20.15.png


Change your code to:
B4X:
Sub addToolbarButtons(lis As List)
   Dim buttons As List
  buttons.Initialize
    Dim b As BarButton
    b.InitializeText(title,title)
    b.Enabled = True
    buttons.Add(b)
  Page1.ToolbarButtons = buttons
End Sub
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
See the documentation:
SS-2014-11-14_11.20.15.png


Change your code to:
B4X:
Sub addToolbarButtons(lis As List)
   Dim buttons As List
  buttons.Initialize
    Dim b As BarButton
    b.InitializeText(title,title)
    b.Enabled = True
    buttons.Add(b)
  Page1.ToolbarButtons = buttons
End Sub

mmmmmm no perfect left = 0 ??? :-(

IMG_0114.PNG



B4X:
Sub addToolbarButtons(lis As List)
       Dim buttons As List
      buttons.Initialize
    For i = 0 To lis.Size-1
        Dim bt As Button
        bt.Initialize("bt",bt.STYLE_SYSTEM)
        bt.Text = lis.Get(i)
        bt.Width = 100%x/lis.Size
        bt.Left = 0
        bt.Top = 0
        bt.Height = 2%y
        bt.Color = Colors.ARGB(64,Rnd(0,255),Rnd(0,255),Rnd(0,255))
        Dim b As BarButton
        b.InitializeCustom(bt)
        b.Enabled = True
           buttons.Add(b)
    Next
      Page1.ToolbarButtons = buttons
End Sub
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
I had to subtract 8% to hit buttons in ToolbarButtons --- for center 3 button :-(

B4X:
Sub addToolbarButtons(lis As List)
      Dim buttons As List
      buttons.Initialize
    For i = 0 To lis.Size-1
        Dim bt As Button
        bt.Initialize("bt",bt.STYLE_SYSTEM)
        bt.Text = lis.Get(i)
        bt.Width = (100%x-8%x)/lis.Size ' <<<<<<<<<<<<<<<<<<<<<<<<<< ???
        bt.Left = -10
        bt.Top = 0
        bt.Height = 2%y
        bt.Color = Colors.ARGB(64,Rnd(0,255),Rnd(0,255),Rnd(0,255))
        Dim b As BarButton
        b.InitializeCustom(bt)
        b.Enabled = True
           buttons.Add(b)
    Next
      Page1.ToolbarButtons = buttons
End Sub
 
Upvote 0
Top