Skip to content Skip to sidebar Skip to footer

When Should Inversebindingadapter Be Used?

Why do I need InverseBindingAdapter in Android DataBinding, When should we use it?

Solution 1:

The word Inverse is really saying everything you need to know, if you think of what DataBinding is actually doing. If you enable DataBinding for your Layout you can perceive it as a pair of two things:

  1. View (all Views included in <layout></layout>)
  2. Model (all variables included in <data></data>)

Regular DataBinding makes sure that a change in the Model will have its effects in the View. It is invoked by @{expression}.

Inverse DataBinding makes sure that a change in the View will have its effects in the Model. It is invoked by @={expression} (the = char is essential here).


If you think what are the ways to make a change in the View, those can be:

  • Changes in content (e.g. text in TextView)
  • Changes of checked state (e.g. in RadioGroup)
  • Changes in focus
  • ...

Some of them are enabled by default and for others you will need to write a custom InverseBindingAdapter. More on that here.


If you still need more information on that topic I suggest you watch Google I/O 2016 presentation on Advanced DataBinding.

Post a Comment for "When Should Inversebindingadapter Be Used?"