36.2 Enabling Data Binding
The first step in using data binding is to enable it within the Android Studio project. This involves adding a new property to the Module level build.gradle file, so open this file (app -> Gradle Scripts -> build.gradle (Module: ViewModelDemo.app)) as highlighted in Figure 36-1:
Figure 36-1
Within the build.gradle file, add the element shown below to enable data binding within the project:
plugins {
id 'com.android.application'
}
android {
buildFeatures {
dataBinding = true
}
compileSdkVersion 29
.
.
}
Once the entry has been added, a yellow bar will appear across the top of the editor screen containing a Sync Now link. Click this to resynchronize the project with the new build configuration settings:
Figure 36-2
...