How to catch the state of toggleButton Android?

Asked

Viewed 352 times

0

How to catch the state of ToggleButton if this on or off, I looked at the Android documentation only has the method of changing the state, I needed to get the status of the button to make the comparison.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.