1

I used the maxLength method. I want you to be notified "Limit characters here are 10 characters" I know the user can't add characters anyway, but I still want to be notified. How do i get when the user is still trying to add characters to throw him an error?

Ziv Sion
  • 165
  • 1
  • 11

1 Answers1

0

I suppose you are talking about an EditText view.
Which one do you use? The Android widget one or the Material one?

Because the Material TextField (https://material.io/develop/android/components/text-fields) has an easy to use character counter:

Google Material docs


If you then want to additionally show an error (e.g. with a Toast) you can get the max length counter by calling yourTextInputLayout.getCounterMaxLenght and check it.

Cyb3rKo
  • 413
  • 7
  • 22