Android Question editText background color

Zizi

Member
Hi there i want to set my edit text to shade red when field is empty or incorrect input, then when a user presses again to re-enter value it goes back to its default (original color which is white background). how can i do that?
 
Solution
1674975409181.png

B4X:
Private Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
    If IsValid(New) Then
        B4XFloatTextField1.mBase.SetColorAndBorder(xui.Color_Transparent, 2dip, xui.Color_Transparent, 2dip)
    Else
        B4XFloatTextField1.mBase.SetColorAndBorder(xui.Color_Transparent, 2dip, xui.Color_Red, 2dip)
    End If
End Sub

Private Sub IsValid(Text As String) As Boolean
    Return Text.StartsWith("A")
End Sub

Using B4XFloatTextField from XUI Views

Erel

B4X founder
Staff member
Licensed User
Longtime User
1674975409181.png

B4X:
Private Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
    If IsValid(New) Then
        B4XFloatTextField1.mBase.SetColorAndBorder(xui.Color_Transparent, 2dip, xui.Color_Transparent, 2dip)
    Else
        B4XFloatTextField1.mBase.SetColorAndBorder(xui.Color_Transparent, 2dip, xui.Color_Red, 2dip)
    End If
End Sub

Private Sub IsValid(Text As String) As Boolean
    Return Text.StartsWith("A")
End Sub

Using B4XFloatTextField from XUI Views
 
Upvote 0
Solution
Top