Adam Varhegyi
Adam Varhegyi

Reputation: 9894

How to catch an EditText's text's length on input?

I want to get the text from an EditText, then get the length of my text, every time the user types or deletes values.

I did it with an InputFilter filter but my experience, that the input filter dont listen for delete key.

So for example if the user writes something to my EditText, then deletes all of it, my toast message wont tell me "0", its just stay at "5" for example (the typed text's length)

Is there a way to get back the EditText's text's length value each time the user types or deletes in it ?

Upvotes: 3

Views: 649

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69218

You should add a TextWatcher using TextView.addTextChangedListener(). Then you will be able to do what you want before, on, or after text changes.

Upvotes: 5

Related Questions