0

I have a Car class implemented like this :

        public class Car extends RealmObject implements Serializable {
       @SerializedName("car_details")
        @Expose
        private RealmList<CarDetail> carDetails = null;
  public RealmList<CarDetail> getCarDetails() {
        return carDetails;
    }

    public void setCarDetails(RealmList<CarDetail> carDetails) {
        this.carDetails = carDetails;
    }
    }

in My trying to access my carDetails from my Layout like this :

<TextView
                                                      android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="8dp"
                            android:text="@{car.carDetails.get(0).grade}"
                            android:textAllCaps="true"
                            android:textColor="@color/black"
                            android:textSize="30sp"
                            android:textStyle="bold" />

but i'm getting an error when compiling , any suggestions how to access the list?

i also tried with :

android:text="@{car.carDetails[0].grade}"

I'm getting an error like this :

error: package me.test.databinding does not exist

It's cannot generate the databinding classes

Capture from the error: enter image description here

Oussaki
  • 1,449
  • 2
  • 21
  • 30
  • What is the error you are getting? – Ayush Khare Sep 04 '17 at 10:16
  • @AyushKhare Error:(14, 39) error: package me.sample.test.databinding does not exist – Oussaki Sep 04 '17 at 11:16
  • Please post the whole error log – Ayush Khare Sep 04 '17 at 14:42
  • The whole error is just this, simply the databinding can not be generated because my code to get a singel item from the RealmList is wrong , if you know how to get specific items from the list in databinding code please tell me – Oussaki Sep 04 '17 at 14:58
  • That's the correct way to get the list object in your data binding, but the real error is not because of it cannot generate data binding. I cannot help you unless you post the full error log – Ayush Khare Sep 04 '17 at 14:59
  • 1
    Have a look at this https://stackoverflow.com/a/33934991/5575410 and this https://stackoverflow.com/a/40494338/5575410 – Ayush Khare Sep 04 '17 at 15:05
  • i edited the question, i added a screen capture of the error Log – Oussaki Sep 04 '17 at 15:08

1 Answers1

2

Seeing you error log screenshot shows the actual problem

Your error: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for rx.Observable not found

FIX:

This can be fixed by either adding RxJava to your project or create an empty dummy file that looks like the following.

package rx;

public class Observable {
    // Dummy class required for Jackson-Databind support if
   // RxJava is not a project dependency.
}

Reference:

See this, this and this

Ayush Khare
  • 1,802
  • 1
  • 15
  • 26