I am trying to make the hint dynamic. of a TextInputLayout
my xml
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/txt_nombre_selecc"
style="@style/outlinedTextInputEditText.Multilines"
android:enabled="false"
android:text="" />
</com.google.android.material.textfield.TextInputLayout>
as you will see I do not assign any hint.
now i initialize it in android
TextInputEditText txt_nombre_selecc = findViewById(R.id.txt_nombre_selecc);
I set the hint according to a condition
if (tipo == 1){
txt_nombre_selecc.setHint("información 1");
}
else{
txt_nombre_selecc.setHint("información 2");
}
up to here it is correct, it does it... without problems.
but then I set the value of the text
txt_nombre_selecc.setText("aca va el nombre");
the TextInputLayout no longer displays the hint and only displays the text.
what is missing?
The hint should be set to the
TextInputLayout
not theTextInputEditText
. Example:The
setHint()
delTextInputEditText
is the same assetPlaceholderText()
theTextInputLayout
. In other words, it sets a text that is only visible when the editText is empty.