Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android- Cannot resolve symbol BaseObservable

I am trying to implement data binding example in android and creating a POJO with bindable variables and i am getting this error ! please help. I am following this tutorial http://www.vogella.com/tutorials/AndroidDatabinding/article.html and here is my code

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);
    }

}
like image 329
ice spirit Avatar asked Jul 13 '17 06:07

ice spirit


1 Answers

You should add these lines of code to your app level gradle file as written in the 1.2 section

android {
    ....
    dataBinding {
        enabled = true
    }
}
like image 155
Jameido Avatar answered Oct 01 '22 21:10

Jameido