Just learned DataBinding
and find out that the powerful built-in toString()
from Kotlin is not available:
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="student"
type="com.example.databindingtest2.Student" />
</data>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{student.name}"
android:textColor="@android:color/black"
android:textSize="30sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@{student.age.toString()}" //doesn't work, age is integer
android:textColor="@android:color/black"
android:textSize="30sp" />
</layout>
I know String.valueOf()
will work, but it's not Kotlin way. Any help would be appreciated.