I've this BindingAdapter
to load image using Glide
in my library module
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
@BindingAdapter("imageUrl")
fun loadImage(view: ImageView, imageUrl: String) {
Glide.with(view)
.load(imageUrl)
.into(view)
}
and I tried to use the adapter like this
<ImageView
...
app:imageUrl="@{`http://pngimg.com/uploads/alfa_romeo/alfa_romeo_PNG75.png`}"
... />
but am getting
****/ data binding error ****msg:Cannot find the setter for attribute 'app:imageUrl' with parameter type java.lang.String on android.widget.ImageView.
The weird thing is, when I convert the BindingAdapter
to Java
from Kotlin
, it works.
public class ImageViewBindingAdapter {
@BindingAdapter("imageUrl")
public static void setImageUrl(ImageView view, String url) {
Glide.with(view)
.load(url)
.into(view);
}
}
NOTE: This issue only exist with the library
module. App module works perfectly fine with the Kotlin
file.
What am I doing wrong ?
Duplicated: https://stackoverflow.com/a/52668004/1607169
TL;DR:
apply plugin: 'kotlin-kapt'
@BindingAdapter("imageUrl")
instead of
@BindingAdapter("app:imageUrl")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With