https://kotlinlang.org logo
Title
a

alle.iacob

01/06/2019, 11:57 PM
@BindingAdapter("app:errorText") fun setErrorText(view: TextInputLayout, errorText: String?) { view.error = errorText }
s

Smorg

01/07/2019, 7:26 AM
Databinding seems a bit tricky to do with Kotlin. Is there a reason you are making the
errorText
nullable? Your code seems fine and should work. You can try making it a non nullable type and try again. If that does not work, try casting the
viewmodel.error
to a String in the layout
<com.google.android.material.textfield.TextInputLayout
                       android:id="@+id/pin_edit_text_layout"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       app:errorEnabled="true"
 app:errorTextAppearance="@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox"
                       app:errorText="@{(String) viewModel.error}>
@alle.iacob
n

nikolay

01/07/2019, 10:38 AM
what is the type for
viewModel.error
? is it
LiveData<String>
?
a

alle.iacob

01/07/2019, 5:14 PM
ObservableField<String>