监听多个EditText,满足条件后Button才可以点击

本文详细介绍了Google文档中的TextWatcher方法,包括afterTextChanged、beforeTextChanged和onTextChanged的使用场景与实现细节。

先翻译下Google文档对TextWatcher的介绍

MethodDescription
abstract void afterTextChanged(Editable s)This method is called to notify you that, somewhere within s, the text has been changed.
abstract void beforeTextChanged(CharSequence s, int start, int count, int after)This method is called to notify you that, within s, the count characters beginning at start are about to be replaced by new text with length after.
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.
方法描述
abstract void afterTextChanged(Editable s)调用此方法会通知你text文本已经变化了, text文本变为s(即变化后最终的text),如果你需要知道Text的那个地方变化了,可以在onTextChanged()中调用setSpan(object,int,int,int)来标记哪个地方变化了
abstract void beforeTextChanged(CharSequence s, int start, int count, int after)调用此方法主要是通知你,文本s将要发生改变,改变前文本的长度为start,变化后,文本长度增加count,新的文本长度为after
abstract void onTextChanged(CharSequence s, int start, int before, int count)调用此方法会通知你,文本变为s,旧文本长度为before,旧文本的长度为start,新文本长度增加了count(一般使用start+count来从s中读取新增文本)

想要进一步对新文本进行变化, 不要在onTextChanged()中, 而要选择在afterTextChanged(),但是不要让自己陷入循环中,因为任何一次文本的变化都会调用afterTextChange()方法而重置变化起始点,想要知道文本哪儿变化了可以考虑在onTextChange()中调用setSpan()给新增文本做标记.

实现多EditText监听: TODO:

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值