rharter / auto-value-gson

AutoValue Extension to add Gson De/Serializer support
Apache License 2.0
607 stars 103 forks source link

use dataBinding error #159

Closed JakeWoki closed 6 years ago

JakeWoki commented 6 years ago
@AutoValue
public abstract class UserInfo {

    public abstract String avatar();

    @SerializedName("username")
    public abstract String userName();

    @SerializedName("realname")
    public abstract String realName();

    public static TypeAdapter<UserInfo> typeAdapter(Gson gson) {
        return new AutoValue_UserInfo.GsonTypeAdapter(gson);
    }
}

<?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="com..model.UserInfo"/>
        <variable name="userInfo" type="UserInfo"/>
    </data>

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                    android:id="@+id/name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/titleColor"
                    android:textSize="24sp"
                    android:text="@={userInfo.userName}"/>

        </LinearLayout>
    </ScrollView>

</layout>

can you give som help?

ZacSweers commented 6 years ago

Let's keep the discussion in #129 rather than make new issues