私はAndroidのデータバインディングに取り組んでおり、次の2つの方法を使用してモデルを設定できるというシナリオに出くわしました:
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);
この2つの違いを説明できる人はいますか?
ユーザー モデル:
public class User{
public String fName;
public String lName;
public User(String fName, String lName){
this.fName = fName;
this.lName = lName;
}
}