Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Buttons(8, 8) As Button
Dim ButtonViews(8,8)
Dim Tile As Bitmap
Dim Background As ImageView
Sub Activity_Create(FirstTime As Boolean)
'Do notSub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("Portrait")
Dim width, height As Int
width = 12.5%x
height = width
Tile.Initialize ( File.DirAssets , "Tile.png")
For x = 0 To 7
For y = 0 To 7
Dim btn As Button
btn.Initialize("button") 'All buttons share the same event sub
btn.SetBackgroundImage(Tile)
btn.Gravity = Gravity.FILL
Activity.AddView(btn, x * width, y * height, width , height)
Buttons(x, y) = btn 'store a reference to this view
Next
Next
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is EditText Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is Label Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
Next
End Sub forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("Portrait")
Dim width, height As Int
width = 12.5%x
height = width
Tile.Initialize ( File.DirAssets , "Tile.png")
For x = 0 To 7
For y = 0 To 7
Dim btn As Button
btn.Initialize("button") 'All buttons share the same event sub
btn.SetBackgroundImage(Tile)
btn.Gravity = Gravity.FILL
Activity.AddView(btn, x * width, y * height, width , height)
Buttons(x, y) = btn 'store a reference to this view
Next
Next
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is EditText Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is Label Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
Next
End Sub