Reputation: 165
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?
Upvotes: 1
Views: 309
Reputation: 464
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:
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.
Upvotes: 0