我试图在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);
    }

}

最佳答案

您应该按照1.2 section的说明将这些代码行添加到应用程序级别的gradle文件中

android {
    ....
    dataBinding {
        enabled = true
    }
}

10-08 16:45