Kotlin Android Tutorial – Age Calculator App

Here is a small Android Kotlin application project for those who are learning Android app development in Kotlin. This is my first Kotlin Android tutorial. I have created AgeCalculator app to give you some hands-on experience in Kotlin. You will learn, How to use Kotlin for Andriod App development.

kotlin android tutorial

Project source code is available to download. Download the project folder and run it on your machine.

Kotlin Android Tutorial – Implementation

If you have the Android Studio version below 3.0, you need to download the Android Studio 3.0 from below link. Android Studio 3.0 has the built-in support for Kotlin. I m using Preview version at this time. It will be available as stable version soon.

Download Android Studio 3.0 (Preview Version)

Create a new Project in Android Studio with default settings, name it AgeCalculator and make sure Include Kotlin support checkbox is selected.

Project Structure:

kotlin android tutorial

Open your MainActivity layout file and add the below code in it.
activity_main.xml

This is very simple layout consisting of EditText, TextView, and Button.

Open your MainActivity class file and add below code in it.
MainActivity.kt

I have implemented onClickListener on Button.

CalAge() function will accept year as string input and calculate the age of the user and return it.

We don’t need to use the FindViewById after importing the above package.

Finally, The AgeCalculator app is ready, Now it is time to Run the application. Watch the video to see the running demo of the AgeCalculator application.

Download Source Code

How to Install Kotlin Plugin in Android Studio 2.XX

This is my first Android app tutorial in Kotlin. I hope you would like this tutorial and learn something useful out of it. If you have any question, you can ask in the comment section.

Connect with AndroidPala on Facebook and Twitter to get new articles and tutorials as soon as they are published.

You can also subscribe to our newsletter to get new tutorials, articles, and other resources right in your inbox.

Email us your feedback and suggestion at admin@androidpala.com

Check Also

asynctask kotlin example

Kotlin AsyncTask Tutorial with Example

Here is an example of implementing AsyncTask in Kotlin. I will create an Android application …