I created a button that when clicked creates the onClick method and makes it a "true" variable
What I want is that if this button is clicked again and the variable ja is true it becomes "false"
I'm using Android Studio, some light?
I created a button that when clicked creates the onClick method and makes it a "true" variable
What I want is that if this button is clicked again and the variable ja is true it becomes "false"
I'm using Android Studio, some light?
There are several ways you can do this, but try it this way:
public class mycActivity ... {
boolean vaiserfalsedepois = false;
// ...
meubotao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
vaiserfalsedepois = !vaiserfalsedepois;
// ou
if (vaiserfalsedepois === true)
vaiserfalsedepois = false;
else
vaiserfalsedepois = true;
// e por ai vai
}
});
}
I hope it helps!
Light and peace!
A simple
variavel = !variavel;
Inside your listener solves your problem.