Java makes your line of code very long while kotlin makes it short and simple
see below how to add a click event a button using java and kotlin
Java button click event
Button btn1 = (Button)findViewById(R.id.button1);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//your stuff here.
}
});
Kotlin button click event
Val btn1 = findViewById<View>(R.id.button1) as Button
btn1.setOnClickListener {
//your stuff here.
}
No comments:
Post a Comment