btn.setonclicklistener() kotlin code example
Example 1: setOnClickListener example kotlin
// set on-click listener
btn_click_me.setOnClickListener {
Toast.makeText(this, "You clicked me.", Toast.LENGTH_SHORT).show()
}
Example 2: kotlin onclicklistener
text_view.setOnClickListener {
val intent = Intent(this@MainActivity, SecondActivity::class.java)
intent.putExtra("key", "Kotlin")
startActivity(intent)
}