Basic of Kotlin to get started in Android Part-5

Kotlin is an awesome language which is implemented by JetBrains. We have practiced many features of Kotlin to build the awesome android application quickly in our last post. If you want to learn how to quick start to using Kotlin language for building Android application.

So do not worry I am here to help you. I would be recommended to checking all my post of Basic of Kotlin to get started in Android part -1, Part-2, part-3, part-4.

In this series today we will learn new hot feature Extensions which is offered by Kotlin. It avoids much boilerplate code which exists in Java. Extensions do not actually insert members into classes, there’s no efficient way for an extension property to have a backing field. This is why initializers are not allowed for extension properties.

Their behavior can only be defined by explicitly providing getters/setters. To get more detail of extensions please check the official documentation of Koltin.

How can We define extensions property in Koltin? Let’s see few example to understand.

In above code, we used extensions feature to set the visibility of progress bar. Generally, we used setter method to set the visibility on Progressbar. But extensions features avoid boilerplate code.

Let’s see few more examples of using.

and create the new fragment to commit to an activity.

Let’s see how we can use extensions feature in Adapter class to set the data model value on Textview.

Ok Great. I loved this extension property feature of Kotlin. I hoping that you also start using this Extensions property feature in the application. Please check another awesome post of Kotlin. Here are details of post API call by using Retrofit, RxJava and RxAndroid in Kotlin Android, Integration of Anko SQLite database in Kotlin Android and MVP design pattern with Dagger2, Retrofit, Anko and RxJava in Kotlin Android.

Here are the best offer and recommendation for you to download this. Please do subscribe your email to get the updated newsletters from this blog and if you feel that this post will help you to understand then do not forget to share and comment below.

Happy Coding 🙂




I am a very enthusiastic Android developer to build solid Android apps. I have a keen interest in developing for Android and have published apps to the Google Play Store. I always open to learning new technologies. For any help drop us a line anytime at

Leave a Reply

Your email address will not be published. Required fields are marked *