Package 

Class DataBindingEpoxyModel


  • 
    public abstract class DataBindingEpoxyModel
    extends EpoxyModelWithHolder<DataBindingEpoxyModel.DataBindingHolder>
                        

    A version of com.airbnb.epoxy.EpoxyModel that can be used with databinding. The layout resource used with this model must be a databinding layout. This class will create the databinding object from the layout and call the setDataBindingVariables methods when the view needs binding to the model.

    The easiest way to use this model is to have Epoxy generate a model to do all the binding work for you. To do this, create an abstract subclass of this model, annotate it with , and pass your layout resource as the layout param. (You must pass the layout this way instead of implementing getDefaultLayout).

    Then, make a field to represent each of the data variables in your layout and annotate each one with EpoxyAttribute. The name of each field must match the name of the variable in the layout exactly.

    Epoxy will generate a subclass of your model at compile time that implements and setDataBindingVariables for you. This will do all binding for you, and also only bind variables that change if you update your model (Note: The change optimization only works when used with ).