What is the Kotlin class?

A class is a program unit that groups together functions and data to perform some tasks.

Kotlin classes/files

We use Kotlin classes in the files that consist of Kotlin code to connect (specific methods) to the (UI elements) that were designed in XML.

With the Android studio, we can use Kotlin library development to build Android Apps.

Note: Method and a function are the same, with different terms.

EX (Kotlin file): MainActivity.kt

When we using Method inside the Kotlin class then we can perform actions on the UI, or the REST API of the application.

Using “method” in the Kotlin class and connect to UI

Tips:

We can use Kotlin file to build Android Apps.

We can use Java file to build Android Apps.

We can use both Kotlin and Java to build Android Apps.

So, let’s start building Interactive App in Kotlin with the source code.

NOTE In this example, I use Android Studio 3.3

AndroidManifest.xml

MainActivity.kt

drawable.xml

drawable2.xml

Inside the layout folder we have:

activity_main.xml

Inside the values folder we have the following:

colors.xml

strings.xml

styles.xml

For Gradle build tool

Gradle Top-level

Gradle app level