Search code examples
androidtextwatcher

TextWatcher not immediately triggered


I have a TextWatcher on an EditText. In afterTextChanged, I have code to do a call to a web service, and get the results. But it is called immediately after the user enters the first character. I want it to trigger only when the user has not been writing on the EditText for a while, so the user can search for two or more characters. How could I do it?

Thanks.


Solution

  • The callback will be called on each added/removed character.

    Start the delay by yourself and cancel it to launch it again whenever you have a change in the EditText.