Android Question Button1.Enable

Discussion in 'Android Questions' started by Isac, Jan 25, 2015.

  1. Isac

    Isac Active Member Licensed User

    Hello
    How do I pass a false when the release button?
    Thank You

    Code:
    Sub Button1_Click
     
       
     
    If Button1.Enabled=True Then
        Button1.Text=
    "ON"
        
    Else
        Button1.Text=
    "OFF"
    End If

    End Sub
     
  2. susu

    susu Well-Known Member Licensed User

    Code:
    Sub Button1_Click

      
    If Button1.Enabled=True Then
        Button1.Text=
    "OFF"
        Button1.Enable = 
    False
        
    Else
        Button1.Text=
    "ON"
        Button1.Enable = 
    True
    End If

    End Sub
     
  3. Isac

    Isac Active Member Licensed User

    It does not change the text, remains locked OFF
     
  4. NJDude

    NJDude Expert Licensed User

    That code won't work because once the button is disabled you cannot click on it, you should use a Toggle button.
     
  5. susu

    susu Well-Known Member Licensed User

    You're right, I replied on my phone and did not check it on B4A.
     
  6. susu

    susu Well-Known Member Licensed User

    Sorry, I was wrong.
    You can use 2 buttons ButtonOn and ButtonOff. You can change the state by using a global var then enable/visible it.
    However, it's better to use Toggle button like NJDude suggested.
     
    Isac likes this.
  7. ivan.tellez

    ivan.tellez Active Member Licensed User

    Thats easy...

    Code:
    Sub Button1_Click

    If Button1.Text="OFF" Then
        Button1.Text=
    "ON"
        
    '...Code to turn on whatever
    Else
        Button1.Text=
    "OFF"
        
    '...Code to turn off whatever
    End If

    End Sub
    Note that the button is never actually disabled.
     
    Last edited: Jan 25, 2015
    susu and Isac like this.
  8. Isac

    Isac Active Member Licensed User

    :)

    Code:
    Sub Button1_Click

    If Button1.Text="OFF" Then
        Button1.Text=
    "ON"
        ...Code 
    to turn on whatever
    Else
        Button1.Text=
    "OFF"
        ...Code 
    to turn off whatever
    End If

    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice