Android Data Binding Error:Execution failed java.lang.RuntimeException:

前端 未结 3 1865
独厮守ぢ
独厮守ぢ 2021-01-22 19:25

I tried to do some analog of example from here: http://www.mutualmobile.com/posts/using-data-binding-api-in-recyclerview And everything works correct except image url binding. I

相关标签:
3条回答
  • 2021-01-22 20:07

    Set the argument of BindingAdapter annotation to "app:imageUrl". So you must have this:

    @BindingAdapter("app:imageUrl")
    

    instead of this:

    @BindingAdapter("bind:imageUrl")
    

    And also what @Alexander Myznikov said - change app.imageUrl to app:imageUrl

    0 讨论(0)
  • 2021-01-22 20:12

    Only try to rename the reference inside of the @BindingAdapter

    @BindingAdapter({"bind:image_url"})
        public static void loadImage(ImageView imageView, String url) {
            Picasso.with(imageView.getContext()).load(url).into(imageView);
        }
    

    And in your layout this:

    ...
    <data>       
        <variable
            name="item"
            type="com.example.Item" />
    </data>
    ...
    
    <ImageView
                android:id="@+id/iv_item"
                app:image_url="@{item.imageUrl}"
                ... />
    ...
    
    0 讨论(0)
  • 2021-01-22 20:16

    Found my problem. Instead of:

    app.imageUrl="@{item.imageUrl}"
    

    Must be:

    app:imageUrl="@{item.imageUrl}"
    
    0 讨论(0)
提交回复
热议问题