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

BaseObservable

public class BaseObservable
extends Object implements Observable

↳ android.databinding.BaseObservable
Known Direct Subclasses
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.
ObservableShort An observable class that holds a primitive short.
ViewDataBinding Base class for generated data binding classes.
Known Indirect Subclasses
ObservableParcelable<T extends Parcelable> An observable class that holds a parcelable object.


A convenience class that implements Observable interface and provides notifyPropertyChanged(int) and notifyChange() methods.

Summary

Public constructors

BaseObservable()

Public methods

void addOnPropertyChangedCallback(Observable.OnPropertyChangedCallback callback)

Adds a callback to listen for changes to the Observable.

void notifyChange()

Notifies listeners that all properties of this instance have changed.

void notifyPropertyChanged(int fieldId)

Notifies listeners that a specific property has changed.

void removeOnPropertyChangedCallback(Observable.OnPropertyChangedCallback callback)

Removes a callback from those listening for changes.

Inherited methods

From class java.lang.Object
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()
From interface android.databinding.Observable
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 constructors

BaseObservable

BaseObservable ()

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.

notifyChange

void notifyChange ()

Notifies listeners that all properties of this instance have changed.

notifyPropertyChanged

void notifyPropertyChanged (int fieldId)

Notifies listeners that a specific property has changed. The getter for the property that changes should be marked with Bindable to generate a field in BR to be used as fieldId.

Parameters
fieldId int: The generated BR id for the Bindable field.

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.