Android-无法解析符号BaseObservable
作者:互联网
我试图在android中实现数据绑定示例,并创建具有可绑定变量的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);
}
}
解决方法:
您应该按照1.2 section的规定将这些代码行添加到应用级gradle文件中
android {
....
dataBinding {
enabled = true
}
}
标签:android-databinding,android 来源: https://codeday.me/bug/20191025/1931875.html