Input errors on Android
Users should be notified when they make input errors. Show a clear error message when data has been entered incorrectly. Furthermore, provide suggestions that help users to fix the error. It is important that error messages are also posted to users of assistive technologies.
On Android, you can use a TextView
to show an error message. The error message should also be posted to assistive technologies by using an accessibility announcement
.
You can also use TextInputLayout
, which makes showing error messages easier. Set setErrorEnabled
to true
and then set the error message by using the setError
method.
textView.setVisibility(View.VISIBLE)
textView.text = "Invalid date, must be in the form DD/MM/YYYY, for example, 01/01/2000"
input.setErrorEnabled(true)
input.setError("Invalid date, must be in the form DD/MM/YYYY, for example, 01/01/2000")