From the course: Learning Kotlin for Android Development

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Convert activity

Convert activity

From the course: Learning Kotlin for Android Development

Start my 1-month free trial

Convert activity

- [Instructor] Now let's take a look at mainactivity.java. Select the mainactivity.java tab. Not much here, but we want it to be a kotlin file. The kotlin plugin will convert java files to kotlin. It doesn't always do the best job, but it will get you started. From the code menu, choose convert java file to kotlin file. From the code menu, choose convert java file to kotlin file. If you see a dialog box, read the warning and select ok. Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too? Just select ok. Now you have a kotlin activity. Notice how the public and extend keywords have disappeared. The at override annotation is now a keyword and the savedInstanceState variable is a nullable variable because it can be null. We will talk about nullable variables later in the course. Almost everything else is the same, except the missing semicolons. This activity sets the layout file, then it finds…

Contents