0

Android Studio 3.1, java 1.8, Gradle 4.5.

Here my activity:

public class OrdersActivity extends AppCompatActivity {

ObservableArrayList<OrderEntry> orderList = new ObservableArrayList<>();

    @Override
    public void setOrderList(List<OrderEntry> list) {
        this.orderList.clear();
        this.orderList.addAll(list);
    }
}

I want to show list's size in layout. So here layout's xml.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.view.View" />

        <variable
            name="handler"
            type="com.myproject.ui.OrdersActivity" />

    </data>

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:visibility="@{handler.orderList.size > 0 ? View.VISIBLE : View.GONE}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </android.support.constraint.ConstraintLayout>   


    </android.support.constraint.ConstraintLayout>
</layout>

But I get error:

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    android.databinding.tool.util.LoggedErrorException: Found data binding errors. ****/ data binding error ****msg:Could not find accessor com.myproject.ui.OrdersActivity.orderList file:\app\src\main\res\layout\orders.xml loc:118:38 - 118:54 ****\ data binding error ****

1 Answer 1

1

Did you try making it public or wrapping it with a public getOrderList()?

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I must add public. So with this public ObservableArrayList<OrderEntry> orderList = new ObservableArrayList<>(); work fine. Thanks

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.