Android data binding expression to Object val error


#1

I can’t get a binding expression to work on a val property in an Object.

<data>
    <import type="letstwinkle.com.twinkle.User" />
</data>

    <ImageView
        android:id="@+id/userAvatar"
        app:layout_widthPercent="18%"
        app:layout_aspectRatio="100%"
        android:layout_alignParentStart="true"
        bind:srcUri="@{User.profile.photos[0].fullSource}"
        />

where User is this

object User {
    val profile: UserProfile by lazy {
        ...
    }
    val account: Account? = Account()
}

but I can’t resolve the error "Error:(26, 28) Could not find accessor letstwinkle.com.twinkle.User.profile "
I have also tried ‘User.getProfile()’. Any tips? :slight_smile:


#2

If I bind the profile to a variable instead

   <variable name="userProfile" type="Profile" />

then the expression @{userProfile.photos[0].fullSource} does not error.