Open AbdElRahmanJamal opened 6 years ago
switch.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_UP) {
// Do what you want
true
} else false
}
If you want to use "switch.isChecked" boolean in a listener you can use @JobGetabu and wrap the switch in a ViewGroup so that you can use "switch.isChecked" in it's listener like this
switch.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_UP) {
switchWrapper.performClick()
true
}
switchWrapper.setOnClickListener {
val newSwitchStatus = status.isChecked().not()
if (newSwitchStatus)
// Do what you want
status.isChecked() = newSwitchStatus
}
@Override public final void setOnClickListener(OnClickListener l) {}
can you please add its implementation