Dear All,
I´m struggling to understand what I´m doing wrong here. The below code loads an activity with a two buttons of various sizes.. When you click the biggest button, it should change the textcolor of all buttons which it does, but it also changes the size of the big button to that of the small one.
Would someone be able to point out what´s going wrong?
Thanks!
I´m struggling to understand what I´m doing wrong here. The below code loads an activity with a two buttons of various sizes.. When you click the biggest button, it should change the textcolor of all buttons which it does, but it also changes the size of the big button to that of the small one.
Would someone be able to point out what´s going wrong?
Thanks!
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim clrs(2) As Int
Dim newbutton As Button
Dim newbutton2 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
newbutton.Initialize("newbutton")
newbutton2.Initialize("newbutton2")
Activity.AddView(newbutton,50%x,50%y,100dip,100dip)
Activity.AddView(newbutton2,75%x,75%y,50dip,50dip)
newbutton.Text = "test"
newbutton2.Text = "test"
Dim grad As GradientDrawable
clrs(0) = Colors.Blue
clrs(1) = Colors.red
grad.Initialize("LEFT_RIGHT",clrs)
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim b As Button = V
b.Background = grad
End If
Next
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub newbutton_Click
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim b As Button = V
b.TextColor = Colors.cyan
v = b
End If
Next
End Sub