Android What is Difference between setVariable(BR.xyz, model) and databinding.setXYZ(model)

后端 未结 2 1216
萌比男神i
萌比男神i 2021-02-13 13:57

I was working on android data-binding and came across the scenario that we can set a model using following two ways:

 User user = new User(\"User\", \"Abc\"); //         


        
2条回答
  •  深忆病人
    2021-02-13 14:19

    They do the same thing. According to the docs, sometimes the type of the variable can't be determined, so you will have to use the setVariable() method. Under normal circumstances, the setX() method(s) will be generated. You are better off using the generated methods.

提交回复
热议问题