Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private B4XFloatTextField1 As B4XFloatTextField
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
B4XFloatTextField1.Tag = B4XFloatTextField1.HintText
B4XFloatTextField1.AnimationDuration = 0
SetTextFieldState(B4XFloatTextField1, True)
End Sub
Private Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
Dim valid As Boolean = New = "" Or IsNumber(New)
SetTextFieldState(Sender, valid)
End Sub
Private Sub SetTextFieldState(tf As B4XFloatTextField, valid As Boolean)
If valid Then
tf.TextField.SetColorAndBorder(xui.Color_White, 1dip, xui.Color_Gray, 5dip)
tf.HintText = tf.Tag
Else
tf.TextField.SetColorAndBorder(xui.Color_White, 2dip, xui.Color_Red, 5dip)
tf.HintText = "invalid number"
End If
tf.Update 'needed because we update the hint text
End Sub