Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change hint text on AppCompatEditText at runtime?

Has anyone figured out a way to change the hint text (the text displayed when the field is empty) at runtime instead of in the layout? The layout looks like this:

      <android.support.design.widget.TextInputLayout
          style="@style/CreateAccount.Zip.Label">
          <android.support.v7.widget.AppCompatEditText
              android:id="@+id/Zip"
              style="@style/CreateAccount.Zip" />
      </android.support.design.widget.TextInputLayout>

The problem I have is that the Material Design field label animation gets broken if I set it at runtime :-( It just stays static if I set it at runtime...no motion at all when you start typing.

like image 748
kenyee Avatar asked Sep 30 '15 18:09

kenyee


1 Answers

You have to change the TextInputLayout hint:

TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.my_text_input_layout);
textInputLayout.setHint("New hint");
like image 59
allo86 Avatar answered Sep 29 '22 14:09

allo86