|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2016-5-13 11:07:01
|
显示全部楼层
Android studio
Data Binding
在gradle中,android下配置
①dataBinding{
enabled=true;
}
②布局中
用<layout> <data>分别处理
③在javabean中,用
@Bindable和notifyPropertyChanged
The Bindable annotation generates an entry in the BR class file during compilation. The BR class file will be generated in the module package. If the base class for data classes cannot be changed, the Observable interface may be implemented using the convenient PropertyChangeRegistry to store and notify listeners efficiently.
④也可以用
A little work is involved in creating Observable classes, so developers who want to save time or have few properties may use ObservableField and its siblings ObservableBoolean, ObservableByte, ObservableChar, ObservableShort, ObservableInt, ObservableLong, ObservableFloat, ObservableDouble, and ObservableParcelable. ObservableFields are self-contained observable objects that have a single field. The primitive versions avoid boxing and unboxing during access operations. To use, create a public final field in the data class:
⑤点击事件
一开始设置handler之后,并没有作用。
后来发现,是没有用binding的set方法给它设置handler
|
|