Directory Introduction website and document Chinese Community Tutorials Articles Open Source Library and framework Demo Other introduction Why do this. On Google I/O this morning, Google officially announced official support for Kotlin. In order to let everyone faster understanding and hands-on Kotlin, here for everyone to tidy up this kotlin resources, hope can
language itself.Why is Kotlin used?
If a programming language is not enough to change your programming thinking, it fails. We are familiar with static languages such as C, Obj-C, and JAVA. It is time to learn dynamic languages such as Swift, Go, and Kotlin.The second reason is that Kotlin can indeed omit a lot of coding and its unique language features.The third
also not possible to add methods that are not relevant to the current class for convenience, such as we want to add a simple dialog extension method for each context, which is obviously not very reasonable because there is a problem with the non-UI context.
What are the core competencies of Android programmers?After the Kotlin came out, two different sounds were heard:
Good, finally can have
installing the Kotlin plugin into Android Studio and creating your first Kotlin application.
For more in-depth introduction, please check the site's reference documents and Kotlin heart print.
Another good resource is Kotlin for
, which is obviously not very reasonable because there is a problem with the non-UI context.What are the core competencies of Android programmers?After the Kotlin came out, two different sounds were heard:Good, finally can have reason to switch to Kotlin, write code more efficient. You can gradually start abandoning java.WTF, but also
Now I am using Kotlin to develop Android for 12 reasons (KAD 30) and kotlinandroid
By Antonio Leiva
Time: Jul, 11,201 7
Link: https://antonioleiva.com/reasons-kotlin-android/
This group of articles has reached the end, and they are very practical. Today I want to talk about why I think it is very interesting to
printSum(a: Int, b: Int) { a3. Main functionArrayString{}4. If condition statementmax(a: Int, b: Int): Int { if(a>b) returna else return b}Simplified notationmax(aif (aaelse b5. Use nullable variables and null values to checkSwift has a type of optionalKotlin also has this type of operationparseIntString): Int?{}It is possible for the function to return an int and possibly return nullSo null judgment is required for useArrayString>) { parseInt(args[0]) pa
follows:
public class YetAnotherActivity : Activity() { private var a: Int = 0 private var b: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) a = 10 b = 20 Log.d("MESSAGE", "The sum is " + (a + b)) }}
In addition to file content changes, the file extension also changes from. java to. kt.Summary
In this article, we learned how to use Kotlin In the
1 Creating a new projectAndroid Studio creates a new project with only one empty mainactivity2 Installing KotlinFile-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 KotlinHttp://plugins.jetbrains.com/pluginManager/?action=downloadid=org.jetbrains.kotlinbuild= ai-162.2228.14uuid=6b417889-78a8-4cc8-ac6c-3e8d64c5a56cDownload to d
Google Android Studio Kotlin Development environment ConfigurationGoogle's recent developer conference announced that Kotlin become the first language of Android development, that is, the official Android language development, it can be seen that Google
. Install Kotlin plug-inTo install the Kotlin plugin, go to the "Preferences" plugins and find it in the search bar:2. Create a new Android projectNow that you have the plug-in installed (and you can install it later), you can create an Android project. This is no different from creating a typical project:Select Blank
code, there are still many differences. In the next article, you can learn this content.
4. convert a project to a Kotlin Project
Another utility can perform this conversion for you. Just goTools> Kotlin> Configure Kotlin in ProjectIn the dialog box, add some changesBuild. gradleFile:
What has this changed? Add the
Issue 1: Create a new Android project that supports Kotlin, stuck in "Resolve Dependency:classpath"Solution Analysis:Generally encountered "Resolve Dependency:classpath" stuck motionless, and so on if still did not respond, should be never response. Restart Android Studio or Gradle sync again, and if not, look at the gradle version of "Gradle-wrapper.properties"
the superiority of the language itself.Why use KotlinSuppose 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 un
GoalThis article is intended to guide developers to use Kotlin to develop Android apps.As for the grammar and tutorials of the Kotlin language, which are not covered in this article, please refer to the following official website documentation and online development tutorials.
Kotlin-
know where to go. Obviously, Kotlin also belongs to the latter.Kotlin has almost all of the syntactic features that C # has and Java does not have, and may be better in some ways. Kotlin has a lot of FP features, but it's not as complex as Scala, and compiles much faster than in Java, so you can learn the advantages of Java and Scala, but discard their drawbacks
About Kotlin, there have been some articles on the web, including Antonio Leiva's blog translation. However, I would like to follow them, translate them, to exercise their English translation. Experts find the problem, please timely "shoot bricks."Original title: Kotlin for Android (I): Introduction (http://antonioleiva.com/k
independent variables.
This is because Java does not have such language features. In Java, you need to solve it by generating function overloading based on your needs.
In Kotlin, you can use @ JvmOverloads to annotate the automatically generated code.
The Code is as follows:
1 class KotlinView @JvmOverloads constructor(2 context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 03 ) : View(context, attrs, defStyleAttr)
Conclusi
What Android Developers should know about KotlinAndroid Developers face a dilemma in terms of language restrictions. As we all know, the current Android development only supports Java 6 (the language itself has been improved since Java 7). Therefore, we can only use one old language for development every day, this greatly reduces our productivity and forces us to write a lot of samples and vulnerable code.
implemented by using functions as parameters, some cannot be called syntax, but functions are nested, infix function call,lambda, function parameters, variable argument lists, flexible tags, powerful return, automatic type judgments, Range,iterator, operator overloading, omitting, template ... These are too many features that cause Kotlin's syntax to dazzle, though sometimes it may seem elegant, but it can also cause great difficulty in reading the code.End this article with a piece of code wit
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.