我正在尝试在 android 中实现数据绑定(bind)示例并创建一个带有可绑定(bind)变量的 POJO,但我收到了这个错误!请帮忙。我正在关注本教程 http://www.vogella.com/tutorials/AndroidDatabinding/article.html这是我的代码
import android.databinding.BaseObservable;
import android.databinding.Bindable;
public class TemperatureData extends BaseObservable {
private String location;
private String celsius;
public TemperatureData(String location, String celsius) {
this.location = location;
this.celsius = celsius;
}
@Bindable
public String getCelsius() {
return celsius;
}
@Bindable
public String getLocation() {
return location;
}
public void setLocation(String location){
this.location = location;
notifyPropertyChanged(BR.location);
}
public void setCelsius(String celsius) {
this.celsius = celsius;
notifyPropertyChanged(BR.celsius);
}
}
最佳答案
您应该将这些代码行添加到您的应用程序级 gradle 文件中,如 1.2 section 中所写
android {
....
dataBinding {
enabled = true
}
}
关于Android-无法解析符号 BaseObservable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45073291/