How to get the status of Android toggleButton?

0

How to get the status of ToggleButton if it is turned on or off, I looked at the documentation of Android only has the method to change the state, had to pick the state of the button to make the comparison.     

asked by anonymous 12.05.2017 / 19:57

1 answer

2

The method is isChecked (). It is inherited from the CompoundButton class.

Ex:

if(myToggleButton.isChecked())
  // Faça algo se estiver checado
else
  // Faça algo se não estiver checado
    
12.05.2017 / 20:04