Reputation: 633
I have seen this code in one of Google's Android examples. Code example here:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.view.View" />
<variable
name="stats"
type="com.example.android.architecture.blueprints.todoapp.statistics.StatisticsViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
<!-- look at this -->
android:text="@{stats.status}"
android:visibility="@{stats.showStatus ? View.VISIBLE : View.GONE}" />
</LinearLayout>
</layout>
I wanted to use something like this for my own project but it did not compile. I suppose that it requires some libraries or something else but I could not find it. Any advice?
Upvotes: 0
Views: 126
Reputation: 35569
enable dataBinding
in your build.gradle
android{
...
...
defaultConfig{
...
...
dataBinding{
enabled true
}
}
}
Upvotes: 4