iOS Question Button's creation programmatically

Giusy

Active Member
Licensed User
Hi, I have to create buttons programmatically, this is the code:
B4X:
Dim x, y As Int
    For y = 0 To ROWs-1
        For x = 0 To columns - 1
            Dim bt As Button
            bt.Initialize("Button",bt.STYLE_SYSTEM) 
            strLines =list1.get(y)
            bt.Text = strLines
            bt.Tag = y*columns
            bt.CustomLabel.Font = Font.CreateNewBold(20)
            bt.CustomLabel.Font = Font.CreateNew(20)
            bt.CustomLabel.Multiline=False
            bt.CustomLabel.TextColor= Colors.RGB(0,0,128)
            bt.CustomLabel.TextAlignment = bt.CustomLabel.ALIGNMENT_LEFT
            ScreenScrollView.Panel.AddView(bt, x*BWidth,y*BHeight+2dip,BWidth,BHeight-4dip)  'Add Button
        Next
    Next
The cycle works correctly, but "ScreenScrollview.panel.addview" does not add any buttons.
Where is the error?
Thanks
 

klaus

Expert
Licensed User
Longtime User
Add this line in the caricare routine:
screenscrollview.panel.Width = screenscrollview.Width
below
screenscrollview.panel.Height =rows*BHeight+2dip
B4X:
screenscrollview.panel.Height = rows * BHeight + 2dip'
screenscrollview.panel.Width = screenscrollview.Width
Why, I don't know, at least it works.
Without having your test project, I wouldn't have found it!
 
Last edited:
Upvote 0
Top