- step 1
dataBinding {
enabled = true
}
- step 2
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<!-- layouts...-->
</layout>
- step3
//ViewDataBinding 应为 布局id+Binding
LayoutIdBinding inflate = DataBindingUtil.inflate(LayoutInflate, LayoutId,null,false);
- step4
setContentView(inflate.getRoot());