Stay organized with collections Save and categorize content based on your preferences.

Observable

public interface Observable

android.databinding.Observable
Known Indirect Subclasses
BaseObservable A convenience class that implements Observable interface and provides notifyPropertyChanged(int) and notifyChange() methods.
ObservableBoolean An observable class that holds a primitive boolean.
ObservableByte An observable class that holds a primitive byte.
ObservableChar An observable class that holds a primitive char.
ObservableDouble An observable class that holds a primitive double.
ObservableField<T> An object wrapper to make it observable.
ObservableFloat An observable class that holds a primitive float.
ObservableInt An observable class that holds a primitive int.
ObservableLong An observable class that holds a primitive long.
ObservableParcelable<T extends Parcelable> An observable class that holds a parcelable object.
ObservableShort An observable class that holds a primitive short.
ViewDataBinding Base class for generated data binding classes.


Observable classes provide a way in which data bound UI can be notified of changes. ObservableList and ObservableMap also provide the ability to notify when changes occur. ObservableField, ObservableParcelable, ObservableBoolean, ObservableByte, ObservableShort, ObservableInt, ObservableLong, ObservableFloat, and ObservableDouble provide a means by which properties may be notified without implementing Observable.

An Observable object should notify the Observable.OnPropertyChangedCallback whenever an observed property of the class changes.

The getter for an observable property should be annotated with Bindable .

Convenience class BaseObservable implements this interface and PropertyChangeRegistry can help classes that don't extend BaseObservable to implement the listener registry.

Summary

Nested classes

class Observable.OnPropertyChangedCallback

The callback that is called by Observable when an observable property has changed.

Public methods

abstract void addOnPropertyChangedCallback(Observable.OnPropertyChangedCallback callback)

Adds a callback to listen for changes to the Observable.

abstract void removeOnPropertyChangedCallback(Observable.OnPropertyChangedCallback callback)

Removes a callback from those listening for changes.

Public methods

addOnPropertyChangedCallback

void addOnPropertyChangedCallback (Observable.OnPropertyChangedCallback callback)

Adds a callback to listen for changes to the Observable.

Parameters
callback Observable.OnPropertyChangedCallback: The callback to start listening.

removeOnPropertyChangedCallback

void removeOnPropertyChangedCallback (Observable.OnPropertyChangedCallback callback)

Removes a callback from those listening for changes.

Parameters
callback Observable.OnPropertyChangedCallback: The callback that should stop listening.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025年02月10日 UTC.