Cannot find the setter for attribute with parameter

前端 未结 7 2185
轮回少年
轮回少年 2020-12-18 18:52

I am working on DataBinding with BindingAdapter. Here is my custom method.

@BindingAdapter(\"{bind:fadevisible}\")
public static vo         


        
相关标签:
7条回答
  • 2020-12-18 19:18

    In my particular case, my BindingAdapter had two parameters, with requireAll, and I had neglected to put one of them on the element in my layout XML. So, like this: (Kotlin, I know)

    @BindingAdapter("app:arg1", "app:arg2", requireAll = true)
    fun MyAdapter(view: ImageView, x: String, y: Int) {
        // ...
    }
    
    <Element app:arg1="@{"foo"}"/>
    

    The error was roughly Cannot find the setter for attribute "app:arg1" with parameter String which is perfectly true, there is no such adapter; there's only one for two args.

    One hint that this was happening was that Android Studio indicated that MyAdapter was an unused function by coloring it grey.

    Obviously a more eloquent error message like "there is no adapter for app:arg1 of type String but there is one for..." (when one of the attribute names matches) would be appreciated, but I won't hold my breath.

    0 讨论(0)
提交回复
热议问题