I need to be notified when a field changed. according to android documentation, Bindable annotation will generate a field in the BR class. (https://developer.android.com/reference/android/databinding/Bindable) but after assigning a @Bindable annotation to a field, I see no field created for that in BR class.
I clean and rebuild the project. but no advantage. even I do invalidate cache and Restart. but nothing
this is my java class
class Job : BaseObservable(), Serializable {
@SerializedName("id")
var id: Int = 0
@SerializedName("title")
var title: String = ""
@SerializedName("is_requested")
var isRequested: Boolean = false
@Bindable get
set(value) {
field = value
notifyPropertyChanged(BR.requested)
}
}
but I have error. BR.requested is unknown...
and this is mr BR class that automatically generated
public class BR {
public static final int _all = 0;
public static final int company = 1;
public static final int jobExperience = 2;
public static final int job = 3;
public static final int educationHistory = 4;
public static final int user = 5;
public static final int userLanguage = 6;
}
as you see, there is no corresponding field for isRequested field of Job.kt in BR class.
Note that you need to apply the kotlin-kapt
plugin.
This answer might be helpful