简体   繁体   English

Android数据绑定:找不到属性app:list的setter

[英]Android data binding : Cannot find setter for attribute app:list

This is my listView 这是我的listView

<ListView
    android:id="@+id/productListView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:list="@{page.results}"/>

I get this error: 我收到此错误:

java.lang.RuntimeException: Found data binding errors. java.lang.RuntimeException:发现数据绑定错误。 ****/ data binding error ****msg:Cannot find the setter for attribute 'app:list' with parameter type java.util.List on android.widget.ListView. **** /数据绑定错误**** msg:在android.widget.ListView上找不到参数类型为java.util.List的属性“ app:list”的设置器。 loc:33:20 - 33:31 ****\\ data binding error **** loc:33:20-33:31 **** \\数据绑定错误****

This is my BindingAdapter 这是我的BindingAdapter

@BindingAdapter({"bind:list"})
public static void bindList(Context context, ListView view, ObservableArrayList<Result> list) {
    ProductsAdapter arrayAdapter = new ProductsAdapter(context,list);
    view.setAdapter(arrayAdapter);
}

Can someone please help with this issue. 有人可以帮忙解决这个问题。

You should leave the bind namespace out. 您应该将bind名称空间保留在外。 Only @BindingAdapter("list") should suffice. @BindingAdapter("list")就足够了。

Additionally you don't need the Context parameter should use List<Result> instead of ObservableArrayList<Result> 另外,您不需要Context参数应该使用List<Result>而不是ObservableArrayList<Result>

@BindingAdapter("list")
public static void bindList(ListView view, List<Result> list) {
    Context context = view.getContext();
    view.setAdapter(new ProductsAdapter(context, list));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在数据绑定中找不到属性的设置器 - Cannot find the setter for attribute in Data binding Android数据绑定BindingAdapter:“找不到设置器” - Android Data Binding BindingAdapter: “Cannot find the setter” AndroidX迁移-数据绑定错误msg:找不到参数类型为int的属性“ android:visibility”的设置器 - AndroidX migration - data binding error msg:Cannot find the setter for attribute 'android:visibility' with parameter type int Android数据绑定:找不到属性android:onClick的setter - Android data binding: can't find setter for attribute android:onClick Android数据绑定:无法找到属性的setter - Android Data Binding : can't find the setter for attribute ****/ 数据绑定错误 ****msg:在 android.widget.ImageView 上找不到参数类型为 java.lang.String 的属性“app:image_url”的设置器 - ****/ data binding error ****msg:Cannot find the setter for attribute 'app:image_url' with parameter type java.lang.String on android.widget.ImageView 具有数据绑定的自定义视图 -> 找不到设置器 - Custom View with data binding -> Cannot find setter 找不到属性 app:visibleGone 的 setter - Cannot find setter for attribute app:visibleGone 找不到属性“ android:text”的设置器 - Cannot find the setter for attribute 'android:text' Android找不到属性错误的设置器 - Android Cannot find the setter for attribute Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM