Button OnClickListener implementation from function in android using kotlin.
Very First Create Button View From .xml File
`<Button
android:id="@+id/btn2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Button2"
android:layout_weight="0.5"/>`
//and create button instance in Activity
private var btn1:Button?=null
or
//For Late Initialization can Follow like this,
private lateinit var btn1:Button
//in onCreate,
btn1=findViewById(R.id.btn1) as Button
btn1?.setOnClickListener { btn1Click() }
//implementing button OnClick event from Function,
private fun btn1Click() {
Toast.makeText(this, "button1", Toast.LENGTH_LONG).show()
}