From the course: Intermediate Kotlin for Android Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Kotlin Android Extensions overview

Kotlin Android Extensions overview

From the course: Intermediate Kotlin for Android Developers

Start my 1-month free trial

Kotlin Android Extensions overview

- [Teacher] Kotlin Android Extensions is a plugin that lets you access your views from your layout XML files in a very simple way. Let's see what we mean by that. Here's a snippet of our layout file. We're showing this one in a TextView with an id of planetDescription. Now if we wanted to set the text of this TextView what do we typically need to do? Let's see. First we create a property for it in our class. This is where we specify the name we want to use and the type. Next, let's say this is a fragment. You would get the view from the findViewById method and then set the result to our property above. And then, finally, potentially somewhere else we get access to our property and then we set our desired text. This should sound very familiar. But if we add the Kotlin Extensions plugin we get to bypass most of these steps and we end up with just this. We can use the id of the element from our layout XML, access it and then modify it. We don't need to do any preliminary setup. Let's see…

Contents