BindingAdapter
  public
  
  
  abstract
  @interface
  BindingAdapter
  
  
      implements
      
        Annotation
      
  
  
| android.databinding.BindingAdapter | 
BindingAdapter is applied to methods that are used to manipulate how values with expressions are set to views. The simplest example is to have a public static method that takes the view and the value to set:
@BindingAdapter("android:bufferType")
 public static void setBufferType(TextView view, TextView.BufferType bufferType) {
     view.setText(view.getText(), bufferType);
 }It is also possible to take previously set values, if the old values are listed first:
@BindingAdapter("android:onLayoutChange")
 public static void setOnLayoutChangeListener(View view, View.OnLayoutChangeListener oldValue,
                                              View.OnLayoutChangeListener newValue) {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
         if (oldValue != null) {
             view.removeOnLayoutChangeListener(oldValue);
         }
         if (newValue != null) {
             view.addOnLayoutChangeListener(newValue);
         }
     }
 }
@BindingAdapter({"android:onClick", "android:clickable"})
 public static void setOnClick(View view, View.OnClickListener clickListener,
                               boolean clickable) {
     view.setOnClickListener(clickListener);
     view.setClickable(clickable);
 }
 A binding adapter may optionally take a class extending DataBindingComponent as the first
 parameter as well. If it does, it will be passed the value passed in during binding, either
 directly in the inflate method or indirectly, using the value from
 getDefaultComponent().
 
If a binding adapter is an instance method, the generated DataBindingComponent will have a getter to retrieve an instance of the BindingAdapter's class to use to call the method.
Summary
| Public methods | |
|---|---|
| 
        
        
        
        
        
        boolean | 
      requireAll()
      Whether every attribute must be assigned a binding expression or if some can be absent. | 
| 
        
        
        
        
        
        String[] | 
      value()
       | 
| Inherited methods | |
|---|---|
|  From
interface 
  
    java.lang.annotation.Annotation
  
 | |
Public methods
requireAll
boolean requireAll ()
Whether every attribute must be assigned a binding expression or if some can be absent. When this is false, the BindingAdapter will be called when at least one associated attribute has a binding expression. The attributes for which there was no binding expression (even a normal XML value) will cause the associated parameter receive the Java default value. Care must be taken to ensure that a default value is not confused with a valid XML value.
| Returns | |
|---|---|
| boolean | whether or not every attribute must be assigned a binding expression. The default value is true. | 
- Annotations
- Interfaces
- Classes- BaseObservable
- CallbackRegistry
- CallbackRegistry.NotifierCallback
- DataBindingUtil
- ListChangeRegistry
- MapChangeRegistry
- MergedDataBinderMapper
- Observable.OnPropertyChangedCallback
- ObservableArrayList
- ObservableArrayMap
- ObservableBoolean
- ObservableByte
- ObservableChar
- ObservableDouble
- ObservableField
- ObservableFloat
- ObservableInt
- ObservableList.OnListChangedCallback
- ObservableLong
- ObservableMap.OnMapChangedCallback
- ObservableParcelable
- ObservableShort
- OnRebindCallback
- PropertyChangeRegistry
- ViewDataBinding
- ViewStubProxy
 
