Developing Android with Kotlin

Source: Internet
Author: User

View all my open source projects "open Source Labs"
Welcome to increase my QQ group: "201055521", this blog client source code download "Please click"

Summary

I first stated that I had not used Kotlin for a very long time, and I almost wrote these articles at the same time as I was studying. I did not try any other alternative language. Like go and Scala. So if you're really thinking about a different development language, I suggest you search for other people's comments on these languages.


This article original, reprint please specify address: http://blog.kymjs.com/

Body

Recently, a new understanding of a programming language. Called Kotlin. Kotlin is an open source project initiated by JetBrains in the first place for internal development. This JetBrains company maybe you haven't heard of, but IntelliJ idea you must have heard, yes, you use the Android Studio Mom is the company's products. Kotlin is JVM-based, and the reason to introduce Kotlin is because it has very high interoperability with Java and good IDE support for it, and of course, the most important. It is relative to Java as the superiority of the language itself.

Why use Kotlin

Suppose a programming language is not enough to change your programming mind. Then it's a failure. We have mastered C, Obj-c, Java and other strongly typed languages, it is time to learn about Swift, Go, Kotlin this weakly typed language.
A second reason. Kotlin really can omit a lot of code writing, and its unique language features.


A third reason. Compared with Sala, go and so on. Kotlin can be perfectly compatible with existing Java code, that is, as we normally use the volley, kjframeforandroid, okhttp and other development framework, in the Kotlin language can still execute normally.

IDE Selection

It's still my style. Practice-oriented, this article first for everyone to explain the development of an Android app with Kotlin Hello World.
First of all, Ide,kotlin also supports the use of Eclipse development, although I am eclipse brain powder, but here I do not say, why you understand, eclipse old. This explains the use of Kotlin to develop Android apps in Androidstudio.

Development environment Configuration

1, start Androidstudio. Command+. Open Preference (Please find your own shortcut keys under Windows), search plugin, open the plugin interface, click Browserepository, Search Kotlin, double-click Install Kotlin and Kotlin Extension for Android. The first one is the Kotlin language support package. The second is an enhanced package of features we'll use later.


If you can't download it because of the wall, I have the first plug-in offline package below my new blog home page (http://kymjs.com/).


2, with the language support package, we will be able to create a new androidproject.

After creating a new normal Androidproject, click Code->convert Java file to Kotlin file. The default shortcut key is a bit verbose, here I directly set the shortcut key to command+5. It's a lot easier to convert later.

After the conversion we will find that our original Java class has changed, observing the file extension and seeing that it has changed from. java to. kt files.
3. Click Tool->kotlin->configure Kotlin in Project
(Incidentally, many of the online tutorials are translated from these four articles, Said need to manually configure the Build.gradle, only these four articles are very early, and now the development of Kotlin can be configured with as one key, we choose the latest 0.12.613 Version number (perhaps you will see a lot of Kotlin M12 on the internet.) M11 and other nouns, that is to refer to the 0.12 here similar to the android17,android22. JAVA8, this version number is called)

4, click OK, next is a long wait, Androidstudio is downloading the relevant configuration (can FQ recommendations FQ). Once the download is complete, we are able to execute the Android app.

The above is Kotlin for Android HelloWorld, the next one we explain the basic grammar of Kotlin and the development of the odd trick.

Developing Android 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.