情况
companion object {
@BindingAdapter(value = ["image_url", "isCircle"], requireAll = false)
fun setImageUrl(view: ImageView, imageUrl: String, isCircle: Boolean) {
}
}
问题
java.lang.IllegalStateException: Required DataBindingComponent is null in class LayoutFeedAuthorBindingImpl. A BindingAdapter in com.***.Companion is not static and requires an object to use, retrieved from the DataBindingComponent. If you don't use an inflation method taking a DataBindingComponent, use DataBindingUtil.setDefaultComponent or make all BindingAdapter methods static.
解决 添加 @JvmStatic
@BindingAdapter(value = ["image_url", "isCircle"], requireAll = false)
@JvmStatic
fun setImageUrl(view: ImageView, imageUrl: String, isCircle: Boolean) {}
网友评论