How to return a boolean on the button

1

I have a button and I want it to be clicked when I return true to if of another class, but I did not find any method how I do it.

Button b = new Button();

Another class:

public static ObservableList getObs(ObservableList<String> obs,ObservableList<String> obs2){ 
    if(Main.b.algumMetodo() == true){
        return obs2;
    }else if(Main.b.algumMetodo() != true){
        return obs;
    }
    return obs;
}

How do I do this?

    
asked by anonymous 09.05.2015 / 19:58

1 answer

1

To receive a notification when the button is clicked:

     b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             // Acão, código aqui é executado.
         }
     });

Edit:

The problem is that the button will only be in the clicked state a few milliseconds - so unless you are calling the function very often the probability of being true is very, very low.

What you could do is to put a boolean in OnClickListener where you can change the state as you like (after a second? 10 seconds? with Thread.sleep() , in a Thread itself, whatever the After the other function is evaluated?).

    
09.05.2015 / 20:26