Just adding something to Pratik Dasa's answer and the discussion with @SimpleGuy in the comments, since I have not enough reputation to comment.
The three methods are also triggered by EditText.setText("your string here")
. That would make a length of 16 (in this case), so count
isn't always 1
.
Please note that the parameter list is not the same for the three methods:
abstract void afterTextChanged(Editable s)
abstract void beforeTextChanged(CharSequence s, int start, int count, int after)
abstract void onTextChanged(CharSequence s, int start, int before, int count)
And this is where the difference is between afterTextChanged
and onTextChanged
: the parameters.
Please also have a look at the accepted answer in this thread: Android TextWatcher.afterTextChanged vs TextWatcher.onTextChanged
count
won't be 1. – Sparid