I have a Switch, or a SwitchCompat rather on my app.
When the user clicks or slides the switch I would like to run some code to determine if they should be allowed to.
I have tried the
setOnCheckedChangeListener and setOnClickListener methods but both allow the graphic of the slider to toggle before running the validation code.
How can I run my own code before anything else when the switch is pressed?
Thanks
you should write your validation code first. if validation is false they not allowed to press switch using setEnabled(false) the else user is allowed to press switch