lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

ObservableChar

public class ObservableChar
extends BaseObservable implements Parcelable, Serializable

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


An observable class that holds a primitive char.

Observable field classes may be used instead of creating an Observable object. It can also create a calculated field, depending on other fields:

public class MyDataObject {
     public final ObservableChar firstInitial = new ObservableChar();
     public final ObservableChar firstInitialCapitalized = new ObservableChar(firstInitial)
         @Override
         public char get() { return Character.toUpperCase(firstInitial.get()); }
     };
 }
Fields of this type should be declared final because bindings only detect changes in the field's value, not of the field itself.

This class is parcelable and serializable but callbacks are ignored when the object is parcelled / serialized. Unless you add custom callbacks, this will not be an issue because data binding framework always re-registers callbacks when the view is bound. A parceled ObservableChar will lose its dependencies.

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ObservableChar> CREATOR

Public constructors

ObservableChar(char value)

Creates an ObservableChar with the given initial value.

ObservableChar()

Creates an ObservableChar with the initial value of 0.

ObservableChar(Observable... dependencies)

Creates an ObservableChar that depends on dependencies.

Public methods

int describeContents()
char get()
void set(char value)

Set the stored 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<ObservableChar> CREATOR

Public constructors

ObservableChar

ObservableChar (char value)

Creates an ObservableChar with the given initial value.

Parameters
value char: the initial value for the ObservableChar

ObservableChar

ObservableChar ()

Creates an ObservableChar with the initial value of 0.

ObservableChar

ObservableChar (Observable... dependencies)

Creates an ObservableChar that depends on dependencies. Typically, ObservableFields are passed as dependencies. When any dependency notifies changes, this ObservableChar also notifies a change.

Parameters
dependencies Observable: The Observables that this ObservableChar depends on.

Public methods

describeContents

int describeContents ()

Returns
int

get

char get ()

Returns
char the stored value.

set

void set (char value)

Set the stored value.

Parameters
value char: The new value

writeToParcel

void writeToParcel (Parcel dest, 
                int flags)

Parameters
dest Parcel

flags int