我正在研究 android 数据绑定,并遇到了我们可以使用以下两种方式设置模型的场景:
User user = new User("User", "Abc"); // this is a model
dataBinding.setVariable(BR.user, user);
dataBinding.executePendingBindings(); // and we have to do this... Why?
我们也可以设置如下:
binding.setUser(user);
谁能解释一下这两者之间有什么区别?
用户模型:
public class User{
public String fName;
public String lName;
public User(String fName, String lName){
this.fName = fName;
this.lName = lName;
}
}