@Bindable 和@get:Bindable

2020-11-04  本文已影响0人  Sarah_love

======================================================================================

1.@get:Bindable的使用 in Kotlin

 @get:Bindable

var capacity: String =vendorProfile.searchCriteria

        ?.let { FacetDataManager(it).guestCapacityDefaultName }

        ?.takeIf { it.isNotEmpty()}

        ?:""

    set(value) {

field = value

notifyPropertyChanged(BR.capacity)

}

======================================================================================

2. @Bindable 在java中

@Bindable

public StringgetName() {

return mName;

}

public void setName(String name) {

this.mName = name;

}

======================================================================================

3. @Bindable 在Kotlin中

a. 

var isAlertsImmediatelyEnable: Boolean

@Bindable

    get() = PushDebugSPHelper.isNotificationsAlertsImmediatelyEnable()

set(isEnable) {

PushDebugSPHelper.setNotificationsAlertsImmediatelyEnable(isEnable)

notifyPropertyChanged(BR.alertsImmediatelyEnable)

}

b. 

@Bindable

lateinit var rsvpNoResponseTitle: String

上一篇 下一篇

猜你喜欢

热点阅读