やりたかったこと
TextInputLayout を使ったテキストフィールドにテキストを指定したかった
やったこと
こんな感じにxmlで TextInputLayout にテキストを指定してみた
<com.google.android.material.textfield.TextInputLayout
~
android:text="@{viewModel.user.name}">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
出たエラー
Cannot find a setter for < com.google.android.material.textfield.TextInputLayout android:text > that accepts parameter type 'java.lang.String'
If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
TextInputLayout では android:text を String 型では受け付けていませんよ、というエラー
解決策
android:text は TextInputEditText の方に書きましょう
<com.google.android.material.textfield.TextInputLayout
~>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.user.name}" />
</com.google.android.material.textfield.TextInputLayout>