How to implement OnClickListener interface in Kotlin as we do in Java, and handle the ids like switch case? For example, I have two buttons and on click of each button, I have to call a function.
Asked
Active
Viewed 4,667 times
2 Answers
4
use the onclickListener interface like this and override its onClick method and you can use WHEN statement as shown! as there is no switch statement in kotlin

Rizwan Atta
- 3,222
- 2
- 19
- 31
0
1: How to implements OnClickLister
button.setOnClickListner{
//call your funtion
}
2: Switch case
We have when
in kotlin instead of a switch
. It's just like switch
with superpowers.
To know more about when
go to this link.

divyanshu bhargava
- 1,513
- 1
- 13
- 24