Android Question How to detect button color and change?

Baris Karadeniz

Active Member
Licensed User
I try to detect button color and change it to another color but I couldn't do. My codes are given below. If the button color is red and pressed on it, button color should change to green. If the button color is green and pressed on it, button color should change to red. What is my fault here?

B4X:
ub BtnSystemOnOff_Click
    If TextFieldimei.Text.Length = 15 Then
    BtnSystemOnOff.Tag = BtnSystemOnOff.Background
    If (BtnSystemOnOff.Tag = Colors.Red) Then
    BtnSystemOnOff.Color = Colors.Green
    Timer1.Enabled=True
    Event = ""
    Else
    BtnSystemOnOff.Color = Colors.Red
    Timer1.Enabled=False
    End If
    Else
    Msgbox(warning1, warningtitle1)
    End If
End Sub
 
Top