Change hint text to AppCompatEditText at runtime?

Has anyone figured out a way to change the tooltip text (the text displayed when the field is empty) at run time, and not in the layout? The layout is as follows:

      <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 is that the animation of the Material Design field label breaks if I set it at runtime :-( It just stays static if I set it at runtime ... no movement whatsoever when entering text.

+4
source share
2 answers

I am using the following:

EditText userInput = (EditText) yourView.findViewById(R.id.yourId);
userInput.setHint("something");
0
source

You need to change the prompt TextInputLayout:

TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.my_text_input_layout);
textInputLayout.setHint("New hint");
+3
source

Source: https://habr.com/ru/post/1609680/


All Articles