TextWatcher 的onTextChanged一个注意点

日志如下图:
TextWatcher 的onTextChanged一个注意点_第1张图片

由此可以看出如果判断输入框中是否已经没有字符时,不可以用count==0判断(英文时还好说,中文时count不对应),
而应该使用

TextUtils.isEmpty(s)

来判断

public abstract void onTextChanged (CharSequence s, int start, int before, int count)

This method is called to notify you that, within s, the count characters beginning at start have just replaced old text that had length before. It is an error to attempt to make changes to s from this callback.

你可能感兴趣的:(android,EditText,Watcher)