Develop Android's Hello kotlin!! with Kotlin

Source: Internet
Author: User

1 Creating a new project

Android Studio creates a new project with only one empty mainactivity

2 Installing Kotlin

File-seeting-plugins-install jetbrains Plugin input Kotlin installation,

If the installation fails, open the C:\Users\ user \. Androidstudio2.3\system\log\idea.log "This file, find Kotlin

Http://plugins.jetbrains.com/pluginManager/?action=download&id=org.jetbrains.kotlin&build= ai-162.2228.14&uuid=6b417889-78a8-4cc8-ac6c-3e8d64c5a56c

Download to d:\kotlin-plugin-1.1.1-release-Studio2.3-1.zip with IE single thread

Click Install plugin from disk for installation, then restart Studio

3 Configuration

Apply the following build.gradle to add

ext.kotlin_version = ' 1.1.1 '

Classpath "Org.jetbrains.kotlin:kotlin-gradle-plugin: $kotlin _version"

Add two lines to the Build.gradle in the app folder

Apply plugin: ' kotlin-android '

Apply plugin: ' kotlin-android-extensions '

and compile "Org.jetbrains.kotlin:kotlin-stdlib: $kotlin _version"

4 Convert Mainactivity.java to Mainactivity.kt

5

Activity_main.xml Delete the original TextView, add the following

<textview
Android:id= "@+id/tv"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "Hello world!"/>

Mainactivity.kt file Additions
Import kotlinx.android.synthetic.main.activity_main.*


Tv.text = "Hello Kotlin"
Tv.textsize = 20.0f

Run!!!!!!!!!!
Have you succeeded?

Develop Android's Hello kotlin!! with Kotlin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.