BR 文件的数据绑定问题
DataBinding Issue with BR file
我正在使用 <include>
在父布局中包含一些布局。
问题:
我的一些 viewModel 字段是在 BR 文件中生成的,有些丢失了。问题是什么?
描述:
<include>
标签包含的布局中使用了缺失的字段。
生成的字段用于父布局。
例如:
在下面的代码中BR.name变量名在 BR 文件中生成并在父布局中使用。
public void setName(String phoneNumber){
this.phoneNumber = phoneNumber;
notifyPropertyChanged(BR.phoneNumber);
}
在下面的代码中,子布局中使用的 BR 文件中缺少密码。
public void setPassword(String password){
this.password = password;
notifyPropertyChanged(BR.password);
}
关于为什么会发生这种情况的任何帮助?
到目前为止我尝试了什么?
我重新启动了 android studio 并使其缓存无效,但仍然面临问题。
万岁!我在 google 的官方网站上找到了解决方案 here。
"The Bindable annotation generates an entry in the BR class file during compilation. "
所以我只需要在 getter 上添加 @Bindable 注释。
我正在使用 <include>
在父布局中包含一些布局。
问题: 我的一些 viewModel 字段是在 BR 文件中生成的,有些丢失了。问题是什么?
描述:
<include>
标签包含的布局中使用了缺失的字段。生成的字段用于父布局。
例如:
在下面的代码中BR.name变量名在 BR 文件中生成并在父布局中使用。
public void setName(String phoneNumber){
this.phoneNumber = phoneNumber;
notifyPropertyChanged(BR.phoneNumber);
}
在下面的代码中,子布局中使用的 BR 文件中缺少密码。
public void setPassword(String password){
this.password = password;
notifyPropertyChanged(BR.password);
}
关于为什么会发生这种情况的任何帮助?
到目前为止我尝试了什么?
我重新启动了 android studio 并使其缓存无效,但仍然面临问题。
万岁!我在 google 的官方网站上找到了解决方案 here。
"The Bindable annotation generates an entry in the BR class file during compilation. "
所以我只需要在 getter 上添加 @Bindable 注释。