Skip to content

Most visited

Recently visited



public abstract @interface InverseBindingAdapter
implements Annotation


InverseBindingAdapter is associated with a method used to retrieve the value for a View when setting values gathered from the View. This is similar to BindingAdapters:

 @InverseBindingAdapter(attribute = "android:text", event = "android:textAttrChanged")
 public static String captureTextValue(TextView view, CharSequence originalValue) {
     CharSequence newValue = view.getText();
     CharSequence oldValue = value.get();
     if (oldValue == null) {
     } else if (!contentEquals(newValue, oldValue)) {

The default value for event is the attribute name suffixed with "AttrChanged". In the above example, the default value would have been android:textAttrChanged even if it wasn't provided.

The event attribute is used to notify the data binding system that the value has changed. The developer will typically create a BindingAdapter to assign the event. For example:

 @BindingAdapter(value = {"android:beforeTextChanged", "android:onTextChanged",
                          "android:afterTextChanged", "android:textAttrChanged"},
                          requireAll = false)
 public static void setTextWatcher(TextView view, final BeforeTextChanged before,
                                   final OnTextChanged on, final AfterTextChanged after,
                                   final InverseBindingListener textAttrChanged) {
     TextWatcher newValue = new TextWatcher() {
         public void onTextChanged(CharSequence s, int start, int before, int count) {
             if (on != null) {
                 on.onTextChanged(s, start, before, count);
             if (textAttrChanged != null) {
     TextWatcher oldValue = ListenerUtil.trackListener(view, newValue,;
     if (oldValue != null) {

Like BindingAdapters, InverseBindingAdapter methods may also take DataBindingComponent as the first parameter and may be an instance method with the instance retrieved from the DataBindingComponent.

See also:


Public methods

String attribute()

The attribute that the value is to be retrieved for.

String event()

The event used to trigger changes.

Inherited methods

From interface java.lang.annotation.Annotation

Public methods


String attribute ()

The attribute that the value is to be retrieved for.



String event ()

The event used to trigger changes. This is used in BindingAdapters for the data binding system to set the event listener when two-way binding is used.


This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)