- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 177字
- 2021-07-02 18:48:32
Using Kotlin in a new Android project
For new Kotlin projects created in Android Studio 3.x, the main activity will be already defined in Kotlin, so that we can start writing Kotlin code right away:

Adding a new Kotlin file is similar to adding a Java file. Simply right-click on a package and select new | Kotlin File/Class:

The reason why the IDE says Kotlin File/Class and not simply Kotlin class, which is analogous to Java class, is that we can have more members defined inside a single file. We will discuss this in more detail in Chapter 2, Laying a Foundation.
Notice that Kotlin source files can be located inside the java source folder. We can create a new source folder for Kotlin, but it is not required:

Running and debugging a project is exactly the same as in Java and does not require any additional steps besides configuring Kotlin in the project:

Starting from Android Studio 3.0, various Android templates will also allow us to select a language. This is the new Configure Activity wizard:

推薦閱讀
- Advanced Splunk
- Expert C++
- 64位匯編語言的編程藝術
- Windows Presentation Foundation Development Cookbook
- Full-Stack Vue.js 2 and Laravel 5
- Learning Apache Kafka(Second Edition)
- 量化金融R語言高級教程
- 大模型RAG實戰:RAG原理、應用與系統構建
- 前端HTML+CSS修煉之道(視頻同步+直播)
- Django 3.0入門與實踐
- Python Interviews
- Python函數式編程(第2版)
- Training Systems Using Python Statistical Modeling
- Python預測之美:數據分析與算法實戰(雙色)
- Java EE 8 and Angular