Android Question create buttons or imageviews by code , use b4x

cup319

Member
it's easy to create buttons by activity,but i can't find an example for b4x

USE ACTICITY,CREATE BUTTONS OR IV BY CODE
USE ACTIVITY:
ImageViews(i).Initialize("ImageView")
Activity.AddView(ImageViews(i),(i Mod AA)*10%x,Floor(i/AA)*(30%y+10%x), 10%x, 30%y)



USE B4X,CREATE BUTTONS OR IV BY CODE,I need an example thanks.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Log("MainPage Create")
   
    Root = Root1
    Root.LoadLayout("MainPage")
   
    Page1.Initialize    'initializes Page1
    B4XPages.AddPage("Page 1", Page1)    'adds Page1 to the B4XPages list



    For l = 0 To 10
        Dim Buttons(10) As B4XView
        Private A1 As Int
        A1=10
        Root.Add(Buttons,Root.width*A1+10dip,10dip,10dip,100dip)  '  it's easy to create buttons by activity,but i can't find an example for b4x  
'        Buttons(l).Initialize("Buttons")
'        Buttons(l).Text =l
        Log(Buttons)
    Next

    FillComboBox

End Sub
 

cup319

Member
sloved


Private Sub B4XPage_Created (Root1 As B4XView)
Log("MainPage Create")

Root = Root1
Root.LoadLayout("MainPage")

Page1.Initialize 'initializes Page1
B4XPages.AddPage("Page 1", Page1) 'adds Page1 to the B4XPages list


For l = 0 To 9
Dim buttons(10) As Button
buttons(l).Initialize("Buttons")
Root.Addview(buttons(l),0, l*0.1*Root.Width, l*0.1*Root.Width, 0.1*Root.Height)

buttons(l).Text =l
Log(buttons)
Next


End Sub
 
Upvote 0
Top