Kotlin setOnClickListener using method reference not working

I tried to use method reference the same way as in Java:

button.setOnClickListener(this::clickListener);

Using Kotlin:

button.setOnClickListener {this::clickListener}

However this doesn't work in Kotlin, the solution is to actually invoke the function withing the labmda expression:

button.setOnClickListener {clickListener()}

Why Kotlin doesn't accept the method reference in this case? Isn't the same principle as with Java?

#java #android #kotlin

4 Likes28.00 GEEK