Android Question Create button in runtime

Code: Copy
Sub Process_Globals
    
    Type Pos(x As Int,y As Int)

End Sub

Code: Copy
Sub Activity_Create(FirstTime As Boolean)

    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Test")

    Buttons

Code: Copy
Sub Buttons
        
    For x = 0 To 2
    For y = 0 To 4
        Dim ButtonX As Button
        Dim PosX As Pos
            PosX.x = x
            PosX.y = y
            ButtonX.Initialize("Button")
        ButtonX.Tag = PosX
        Activity.AddView(ButtonX,x*33%x,y*20%y,33%x,20%y)         
    Next
    Next
    
End Sub

Sub Button_Click
    
    Dim Button1 As Button
    Button1 = Sender
    
    Dim Pos1 As Pos
    Pos1 = Button1.Tag   
        
    Log(Pos1.x & " " & Pos1.y)
    
End Sub
 
Upvote 0
if Y value is Dynamic,then how to calculate %x and %y ???

I means,It should be scrollable if rows is greater than 15.........
 
Upvote 0
That would be fine too

Code: Copy
Sub Button_Click
    
    Dim Button1 As Button
    Button1 = Sender
    
    Log(Button1.Left & " " & Button1.Top)
    
End Sub
 
Upvote 0
if Y value is Dynamic,then how to calculate %x and %y ???
then u use dip as size, it will have at all devices the same height.
Code: Copy
y*100dip
 
Upvote 0
Back
Top