loading...

Starting activities with buttons using Kotlin

ajibsbaba profile image Ajibade Samuel ・1 min read

I just started android development and i had some issues which i would like to address for beginners so that they wouldn't have to go through too much stress to solve issues relating to android development with the Kotlin programming language.

First of all you have state the id for your button so let's assume the id for my button = btnLogin
You will call on "setOnClickListener" which listens to button clicks, then you will have to call on the name of the activity in order to start it.
"this" refers to the context of the application

btnLogin.setOnClickListener {
startActivity(Intent(this, LoginActivity:class.java))
}

Thanks for reading.

Discussion

pic
Editor guide