Introduction to Kotlin (1) Record

1. Android studio 3.0.1 already supports Kotlin language by default. You don’t need to install Kotlin plugin. If you don’t worry, you can go to "Command+," in preferences to check whether Kotlin is installed in plugin.

2. Create a new project->select MainActivity-> menu bar code->Convert Java File to Kotlin File, you will see that the code style has changed to Kotlin, and the compiler will remind you that Kotlin has not been configured, click "configure" on the right , The build.gradle under the app and build.gradle under the root directory will change, adding

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

And manually add apply plugin:'kotlin-android-extensions'

apply plugin: 'kotlin-android-extensions'


Set the id of the control in 3.xml

4. Set text/register click event:




Guess you like

Origin blog.csdn.net/qingwangwang/article/details/80802760