DataBinding can do lots of things...
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
gradle/wrapper
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

AndroidDataBindingTutorial

DataBinding can do lots of things...

Advanced Data Binding - Google I/O 2016

DataBindingTutorial-CN

WARNING

  • Data Binding does not support Jack

Error:Data Binding does not support Jack builds yet

Feature

The following features is presented:

Simple usage in Activity(clickListener,map)
LoadImage(ImageView imageView, String url, Drawable error)
Data binding in Fragment
Data binding in RecyclerView
Data binding in ViewPage
Data binding with ObservableField
Data binding with extends BaseObservable
Data binding with implements Observable
Reverse Data Binding

good practices

android:onClick="@{() -> onClickEvent.onClick()}"
android:onClick="@{(v) -> selectedClick.onClick(v, info)}"
android:onCheckedChanged="@{(cb, isChecked) -> presenter.completeChanged(t, isChecked)}"
<!-- view with the id as a variable -->
android:visibility="@{tvView.visibility}"

<import type="android.databinding.ObservableBoolean"/>
<variable name="isVisible" type="ObservableBoolean"/>
// use isVisible.get the value
app:isVisibleOrGone="@{!(isVisible.get)}

<!-- Expression Language: and &&  -->
app:isVisibleOrGone="@{!TextUtils.isEmpty(userName) &amp;&amp; isVisible}"

<!-- 2-way Data Binding -->
android:text="@={defValue}"

Data binding in RecyclerView

data-binding-recycle-view

Data binding in ViewPage

data-binding-view-page


License

This project is licensed under the terms of the MIT license.