Please tell me why binding cannot find bindingConvertion? In the markup in the text attribute put the value of the field of type int:
<TextView android:id="@+id/user_age" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:text='@{TextUtils.isEmpty(String.valueOf(user.age)) ? "No age" : user.age}' app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/user_name" />
Next, in a separate class, I am writing the convertr:
public class BindingConverters { @BindingConversion public static String intToString(int age){ return String.valueOf(age); } }
I get an exception:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.CharSequence
Why is that?