Consider the case when you have an abstract class that does not have a common binding template (except, of course, the ViewDataBinding superclass, which inherits all binding layouts):
public abstract classs EditorActivityFragment<T extends ViewDataBinding> {
In this' onCreateView() class, you cannot use any generated methods to bind a variable to a binding, since there is no common superclass except ViewDataBinding, so you will be forced to use reflection or you can use the convenience method setVariable() :
binding.setVariable(BR.viewModel,myViewModel);
Hope this helps to better explain the use case for this method.
source share