-2

enter image description here

when input is not valid, instead of toast or sth else this kind of new thing appears to warn the user . Does anyone know how I can use it in my own app ? Image is attached . Tnx in advance .

  • Possible duplicate of [Design Android EditText to show error message as described by google](http://stackoverflow.com/questions/30953449/design-android-edittext-to-show-error-message-as-described-by-google) – ShahiM Apr 02 '17 at 11:19
  • see [this answer](http://stackoverflow.com/a/30953551/3894781) – ShahiM Apr 02 '17 at 11:20

2 Answers2

0

That pop up is an error pop up which appears when error is set.

TextInputLayout til = (TextInputLayout) findViewById(R.id.text_input_layout);
til.setError("Your error");
mr_sh
  • 304
  • 1
  • 10
0

You need to call myEditText.setError("insert error message here") One gotcha is that ifmyEditText is not the one that is currently focused you will not see the error message itself, just the exclamation mark like in the below example. enter image description here

To avoid this you should always call myEditText.requestFocus() before calling setError

Lastly, to clear the error just call myEditText.setError(null)

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34