How do I get the switch back to the "fake" state?

Asked

Viewed 41 times

0

I created a switch that turns bluetooth on and off. However, when connecting, it asks the user if he really wants to activate bluetooth. If the user clicks no, the switch remains active and the app crusha.

Does anyone know how to get the Switch back to its initial position if the user clicks not ?

I am using On checked as below:

comum.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            // Ligado
        } else {
            // Desligado
        }
    }
});
  • Thank you very much, I’m new here.

  • 1

    buttonView.isChecked = false. Take into account that this will eventually make the method onCheckedChanged() be called again.

  • Thank you very much, it makes sense, really worth !!!

No answers

Browser other questions tagged

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