Data binding
Android supports a mechanism for data binding so that data is bound with views and the glue code is minimized. Enable data binding by updating your build Gradle configuration as follows:
android { .... dataBinding { enabled = true } } ... dependencies { ... kapt 'com.android.databinding:compiler:2.3.1' } ...
Now, you can define your binding expressions. Take a look at the following example:
<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <variable name="note" type="com.journaler.model.Note" /> </data> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android...