[android] Android - How to achieve setOnClickListener in Kotlin?

I wanted to know that how we set basic onClickListener in Kotlin for Android Development.

This question is related to android listener kotlin

The answer is


Suppose you have textView to click

text_view.text = "Hello Kotlin";

text_view.setOnClickListener {
    val intent = Intent([email protected], SecondActivity::class.java)
    intent.putExtra("key", "Kotlin")
    startActivity(intent)
}

Similar questions with android tag:

Similar questions with listener tag:

Similar questions with kotlin tag: