Most visited

Recently visited

ObservableBoolean

public class ObservableBoolean
extends BaseObservable implements Parcelable, Serializable

java.lang.Object
   ↳ android.databinding.BaseObservable
     ↳ android.databinding.ObservableBoolean


一个拥有原始布尔值的可观察类。

可以使用Observable字段类来代替创建Observable对象:

public class MyDataObject {
     public final ObservableBoolean isAdult = new ObservableBoolean();
 }
Fields of this type should be declared final because bindings only detect changes in the field's value, not of the field itself.

这个类是可parcelable和可序列化的,但当对象被分组/序列化时,回调会被忽略。 除非添加自定义回调,否则这不会成为问题,因为数据绑定框架在视图绑定时总是重新注册回调。

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ObservableBoolean> CREATOR

Public constructors

ObservableBoolean(boolean value)

用给定的初始值创建一个ObservableBoolean。

ObservableBoolean()

创建一个初始值为 false的ObservableBoolean。

Public methods

int describeContents()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。

boolean get()
void set(boolean value)

设置存储的值。

void writeToParcel(Parcel dest, int flags)

将此对象平铺到一个包裹中。

Inherited methods

From class android.databinding.BaseObservable
From class java.lang.Object
From interface android.databinding.Observable
From interface android.os.Parcelable

Fields

CREATOR

Creator<ObservableBoolean> CREATOR

Public constructors

ObservableBoolean

ObservableBoolean (boolean value)

用给定的初始值创建一个ObservableBoolean。

Parameters
value boolean: the initial value for the ObservableBoolean

ObservableBoolean

ObservableBoolean ()

创建一个初始值为 false的ObservableBoolean。

Public methods

describeContents

int describeContents ()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

get

boolean get ()

Returns
boolean the stored value.

set

void set (boolean value)

设置存储的值。

Parameters
value boolean

writeToParcel

void writeToParcel (Parcel dest, 
                int flags)

将此对象平铺到一个包裹中。

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Hooray!