I am learning Kotlin. Before that, I have worked with Java for Android Development. Kotlin is a great language to learn. I have a confusion while I was using setOnClickListener(View.OnClickListener)
. I have seen two hints on Android Studio.
I know how to work or define both of them.
The first way to implementing OnClickListerner
send_button.setOnClickListener(object : View.OnClickListener{
override fun onClick(p0: View?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
})
and this is the second way of implementing OnClickListener
send_button.setOnClickListener {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
I understand as far as the second method is based on lambda. But I can't have the proper understanding of these methods.
So, my question is: What is the difference between those methods? If they differ, which one is better and why?