0

This is my 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. ****/ data binding error ****msg:Cannot find the setter for attribute 'app:list' with parameter type java.util.List on android.widget.ListView. loc:33:20 - 33:31 ****\ data binding error ****

This is my 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.

1 Answer 1

3

You should leave the bind namespace out. Only @BindingAdapter("list") should suffice.

Additionally you don't need the Context parameter should use List<Result> instead of ObservableArrayList<Result>

@BindingAdapter("list")
public static void bindList(ListView view, List<Result> list) {
    Context context = view.getContext();
    view.setAdapter(new ProductsAdapter(context, list));
}
Sign up to request clarification or add additional context in comments.

2 Comments

I tried your suggestion. It still gives the same error.
You might need to use List instead of ObservableArrayList.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.