From the course: Android Development Essential Training: Manage Data with Kotlin

Unlock the full course today

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

Display details with data binding

Display details with data binding

From the course: Android Development Essential Training: Manage Data with Kotlin

Start my 1-month free trial

Display details with data binding

- [Narrator] Android's Data Binding Library lets you display data in the user interface, with simple expressions in the XML layout file. It eliminates boilerplate code such as getting reference to view objects with the find view by ID function. And it moves the logic of displaying data into the file that defines the screen's appearance. The first step in using data binding is to activate it in the module's Gradle build file. I'll open build.gradle from the app module and up here I'll first add a bit of code that applies a plug-in called kotlin-kapt or kapt. This is the annotation processor for Kotlin, and if you're working with data binding and Kotlin, it's required. Next, I'll go down to the Android element and at the bottom, I'll add dataBinding and this is case sensitive, spell it exactly as you see here. And then, enabled = true. And then, sync your Gradle project. Next, I need a layout. I'm going to work with the layout for my detail fragment, which right now, just has a single…

Contents