I am trying to refresh a label when a value is updated. I haven't yet used invalidate so I made the quick sample below to play around with and learn with - with no luck. Am I not understanding or using invalidate properly?
B4X:
Sub Activity_Create(FirstTime As Boolean)
label1.Initialize("panel1")
button1.Initialize("button1")
value1 = 25
label1.Gravity = Gravity.CENTER
label1.Text = "Value is: " & value1
Activity.AddView(label1,0,0,100%x,50%y)
Activity.AddView(button1,0,50%y,100%x,50%y)
End Sub
Sub button1_Click
value1 = value1 - 1
ToastMessageShow(value1,True)
label1.Invalidate
End Sub
Sub Globals
Dim value1 As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
label1.Initialize("label1")
button1.Initialize("button1")
value1 = 25
label1.Gravity = Gravity.CENTER
label1.Text = "Value is: " & value1
Activity.AddView(label1,0,0,100%x,50%y)
Activity.AddView(button1,0,50%y,100%x,50%y)
End Sub
Sub button1_Click
value1 = value1 - 1
label1.Text = value1
ToastMessageShow(value1,True)
End Sub
INVALIDATE is used to refresh or redraw the Activity, not to assign values.