DataBinding笔记4

刷新数据
方式一 直接更改属性数据即可

class House : BaseObservable() {
    @Bindable
    var address: String = ""
        set(value) {
            field=value
            notifyPropertyChanged(BR.address)
        }
    @Bindable
    var size: Int = 0
        set(value) {
            field = value
            notifyPropertyChanged(BR.size)
        }

    @Bindable
    var number: String = ""
        set(value) {
            field = value
            notifyPropertyChanged(BR.number)
        }

}

方式二 修改和属性赋值需要调用set

class House {
    var address: ObservableField = ObservableField()
    var size: ObservableInt = ObservableInt()
    var number: ObservableField = ObservableField()
}

你可能感兴趣的:(DataBinding笔记4)