<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"姓名:" + user.name}' /> String user.name 正確
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{user.lolita ? "蘿莉" : "不是蘿莉"}' /> boolean user.lolita 正確
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{user.age + "歲數(shù)"}' /> int user.age 正確
注意事項(xiàng)
使用中文字符串相加的時(shí)候必須是偶數(shù),如果是奇數(shù)如
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{user.age + "歲"}' />
就會(huì)編譯失敗

解決辦法
在strings.xml 定義中文,然后在布局文件引用
android:text='@{user.age + @string/sui}'