# InverseBindingMethod

Summary:[Methods](https://developer.android.com/reference/android/databinding/InverseBindingMethod#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/databinding/InverseBindingMethod#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/databinding/InverseBindingMethod#)  

# InverseBindingMethod

`
public


abstract
@interface
InverseBindingMethod
`  
`


implements

`[Annotation](http://developer.android.com/reference/java/lang/annotation/Annotation.html)`


`

|------------------------------------------|
| android.databinding.InverseBindingMethod |

<br />

*** ** * ** ***

InverseBindingMethod is used to identify how to listen for changes to a View property and which getter method to call. InverseBindingMethod should be associated with any class as part of[InverseBindingMethods](https://developer.android.com/reference/android/databinding/InverseBindingMethods).

<br />

```
 @InverseBindingMethods({@InverseBindingMethod(
     type = android.widget.TextView.class,
     attribute = "android:text",
     event = "android:textAttrChanged",
     method = "getText")})
 public class MyTextViewBindingAdapters { ... }
 
```

`method`is optional. If it isn't provided, the attribute name is used to find the method name, either prefixing with "is" or "get". For the attribute`android:text`, data binding will search for a`public CharSequence getText()`method on[TextView](http://developer.android.com/reference/android/widget/TextView.html).

`event`is optional. If it isn't provided, the event name is assigned the attribute name suffixed with`AttrChanged`. For the`android:text`attribute, the default event name would be`android:textAttrChanged`. The event should be set using a[BindingAdapter](https://developer.android.com/reference/android/databinding/BindingAdapter). 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() {
         ...
         @Override
         public void onTextChanged(CharSequence s, int start, int before, int count) {
             if (on != null) {
                 on.onTextChanged(s, start, before, count);
             }
             if (textAttrChanged != null) {
                 textAttrChanged.onChange();
             }
         }
     }
     TextWatcher oldValue = ListenerUtil.trackListener(view, newValue, R.id.textWatcher);
     if (oldValue != null) {
         view.removeTextChangedListener(oldValue);
     }
     view.addTextChangedListener(newValue);
 }
 
```

<br />

**See also:**

- [InverseBindingAdapter](https://developer.android.com/reference/android/databinding/InverseBindingAdapter)
- [InverseBindingListener](https://developer.android.com/reference/android/databinding/InverseBindingListener)

## Summary

|                                                                                                                             ### Public methods                                                                                                                              ||
|---------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[String](http://developer.android.com/reference/java/lang/String.html) | ` `[attribute](https://developer.android.com/reference/android/databinding/InverseBindingMethod#attribute())`() ` The attribute that supports two-way binding.                                   |
| ` `[String](http://developer.android.com/reference/java/lang/String.html) | ` `[event](https://developer.android.com/reference/android/databinding/InverseBindingMethod#event())`() ` The event used to notify the data binding system that the attribute value has changed. |
| ` `[String](http://developer.android.com/reference/java/lang/String.html) | ` `[method](https://developer.android.com/reference/android/databinding/InverseBindingMethod#method())`() ` The getter method to retrieve the attribute value from the View.                     |
| ` `[Class](http://developer.android.com/reference/java/lang/Class.html)   | ` `[type](https://developer.android.com/reference/android/databinding/InverseBindingMethod#type())`() ` The View type that is associated with the attribute.                                     |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/databinding/InverseBindingMethod#)From interface` `[java.lang.annotation.Annotation](http://developer.android.com/reference/java/lang/annotation/Annotation.html)` ` |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` abstract `[Class](http://developer.android.com/reference/java/lang/Class.html)`<? extends `[Annotation](http://developer.android.com/reference/java/lang/annotation/Annotation.html)`>` | ` annotationType() `                                                                      | | ` abstract boolean`                                                                                                                                                                       | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` abstract int`                                                                                                                                                                           | ` hashCode() `                                                                            | | ` abstract `[String](http://developer.android.com/reference/java/lang/String.html)                                                                                                        | ` toString() `                                                                            | ||

## Public methods

### attribute

```
String attribute ()
```

The attribute that supports two-way binding.

<br />

|                                    Returns                                     ||
|------------------------------------------------------------------------|--------|
| [String](http://developer.android.com/reference/java/lang/String.html) | <br /> |

### event

```
String event ()
```

The event used to notify the data binding system that the attribute value has changed. Defaults to attribute() + "AttrChanged"

<br />

|                                    Returns                                     ||
|------------------------------------------------------------------------|--------|
| [String](http://developer.android.com/reference/java/lang/String.html) | <br /> |

### method

```
String method ()
```

The getter method to retrieve the attribute value from the View. The default is the bean method name based on the attribute name.

<br />

|                                    Returns                                     ||
|------------------------------------------------------------------------|--------|
| [String](http://developer.android.com/reference/java/lang/String.html) | <br /> |

### type

```
Class type ()
```

The View type that is associated with the attribute.

<br />

|                                   Returns                                    ||
|----------------------------------------------------------------------|--------|
| [Class](http://developer.android.com/reference/java/lang/Class.html) | <br /> |

-

  ## Annotations

  - [Bindable](https://developer.android.com/reference/android/databinding/Bindable)
  - [BindingAdapter](https://developer.android.com/reference/android/databinding/BindingAdapter)
  - [BindingConversion](https://developer.android.com/reference/android/databinding/BindingConversion)
  - [BindingMethod](https://developer.android.com/reference/android/databinding/BindingMethod)
  - [BindingMethods](https://developer.android.com/reference/android/databinding/BindingMethods)
  - [InverseBindingAdapter](https://developer.android.com/reference/android/databinding/InverseBindingAdapter)
  - [InverseBindingMethod](https://developer.android.com/reference/android/databinding/InverseBindingMethod)
  - [InverseBindingMethods](https://developer.android.com/reference/android/databinding/InverseBindingMethods)
  - [InverseMethod](https://developer.android.com/reference/android/databinding/InverseMethod)
-

  ## Interfaces

  - [DataBindingComponent](https://developer.android.com/reference/android/databinding/DataBindingComponent)
  - [InverseBindingListener](https://developer.android.com/reference/android/databinding/InverseBindingListener)
  - [Observable](https://developer.android.com/reference/android/databinding/Observable)
  - [ObservableList](https://developer.android.com/reference/android/databinding/ObservableList)
  - [ObservableMap](https://developer.android.com/reference/android/databinding/ObservableMap)
-

  ## Classes

  - [BaseObservable](https://developer.android.com/reference/android/databinding/BaseObservable)
  - [CallbackRegistry](https://developer.android.com/reference/android/databinding/CallbackRegistry)
  - [CallbackRegistry.NotifierCallback](https://developer.android.com/reference/android/databinding/CallbackRegistry.NotifierCallback)
  - [DataBindingUtil](https://developer.android.com/reference/android/databinding/DataBindingUtil)
  - [ListChangeRegistry](https://developer.android.com/reference/android/databinding/ListChangeRegistry)
  - [MapChangeRegistry](https://developer.android.com/reference/android/databinding/MapChangeRegistry)
  - [MergedDataBinderMapper](https://developer.android.com/reference/android/databinding/MergedDataBinderMapper)
  - [Observable.OnPropertyChangedCallback](https://developer.android.com/reference/android/databinding/Observable.OnPropertyChangedCallback)
  - [ObservableArrayList](https://developer.android.com/reference/android/databinding/ObservableArrayList)
  - [ObservableArrayMap](https://developer.android.com/reference/android/databinding/ObservableArrayMap)
  - [ObservableBoolean](https://developer.android.com/reference/android/databinding/ObservableBoolean)
  - [ObservableByte](https://developer.android.com/reference/android/databinding/ObservableByte)
  - [ObservableChar](https://developer.android.com/reference/android/databinding/ObservableChar)
  - [ObservableDouble](https://developer.android.com/reference/android/databinding/ObservableDouble)
  - [ObservableField](https://developer.android.com/reference/android/databinding/ObservableField)
  - [ObservableFloat](https://developer.android.com/reference/android/databinding/ObservableFloat)
  - [ObservableInt](https://developer.android.com/reference/android/databinding/ObservableInt)
  - [ObservableList.OnListChangedCallback](https://developer.android.com/reference/android/databinding/ObservableList.OnListChangedCallback)
  - [ObservableLong](https://developer.android.com/reference/android/databinding/ObservableLong)
  - [ObservableMap.OnMapChangedCallback](https://developer.android.com/reference/android/databinding/ObservableMap.OnMapChangedCallback)
  - [ObservableParcelable](https://developer.android.com/reference/android/databinding/ObservableParcelable)
  - [ObservableShort](https://developer.android.com/reference/android/databinding/ObservableShort)
  - [OnRebindCallback](https://developer.android.com/reference/android/databinding/OnRebindCallback)
  - [PropertyChangeRegistry](https://developer.android.com/reference/android/databinding/PropertyChangeRegistry)
  - [ViewDataBinding](https://developer.android.com/reference/android/databinding/ViewDataBinding)
  - [ViewStubProxy](https://developer.android.com/reference/android/databinding/ViewStubProxy)