How to make it so that when you click on the Switch, it does not switch, but the click was perceived by him? Since the dialog is assigned by pressing

  • 3
    What kind of switch is one that does not switch, but it brings up dialogs, there are other controls for this. - pavlofff 5:09
  • 3
    If you need a Switch that does not switch, use the button with the switch background instead. - Vladyslav Matviienko

1 answer 1

Just make the switch inactive and hang a click listener on it.

 switch.setEnabled(false); switch.setOnClickListener(...); 
  • And if I use the same onClick in the markup, it will not work, it turns out? - turok09
  • Then just remove the second line from the answer. - Yuriy SPb
  • If you remove, then when you press the switch, nothing happens - turok09
  • 2
    Then leave ... - YuriySPb
  • one
    @ YuriySPb Schrödinger - Silento