TextWatcher 的onTextChanged一个注意点

来源:互联网 发布:逆战一键瞬狙最快数据 编辑:程序博客网 时间:2024/06/06 20:41

日志如下图:
这里写图片描述

由此可以看出如果判断输入框中是否已经没有字符时,不可以用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.

0 0
原创粉丝点击