美文网首页
Kotlin BindingAdapter:Companion

Kotlin BindingAdapter:Companion

作者: 叛逆的曾小砂 | 来源:发表于2020-03-16 21:57 被阅读0次

    情况

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

    相关文章

      网友评论

          本文标题:Kotlin BindingAdapter:Companion

          本文链接:https://www.haomeiwen.com/subject/xftaehtx.html