TextWatcher参数理解

class MyTextWatcher implements TextWatcher{

		@Override
		public void afterTextChanged(Editable s) {
			// s是文本改变后的内容
			Log.i("afterTextChanged", "afterTextChanged the text's length is "+etTest.length());
			Log.i("afterTextChanged", "afterTextChanged the s is "+s.toString());
			Log.i("afterTextChanged", "-------------------------------------");
		}

		@Override
		public void beforeTextChanged(CharSequence s, int start, int count,
				int after) {
			// s是文本改变前的内容
			// start是文本改变操作后输入光标所在位置
			// count删除内容时是删除字符的个数,增加内容时为0
			// after增加内容时是增加字符的个数,删除内容时为0
			// 通过组件索引获得的text内容是改变前的
			Log.i("beforeTextChanged", "beforeTextChanged the text's content is "+etTest.getText().toString());
			Log.i("beforeTextChanged", "beforeTextChanged the text's length is "+etTest.length());
			Log.i("beforeTextChanged", "beforeTextChanged the s is "+s);
			Log.i("beforeTextChanged", "beforeTextChanged the start is "+start);
			Log.i("beforeTextChanged", "beforeTextChanged the count is "+count);
			Log.i("beforeTextChanged", "beforeTextChanged the after is "+after);
			Log.i("beforeTextChanged", "-------------------------------------");
		}

		@Override
		public void onTextChanged(CharSequence s, int start, int before,
				int count) {
			// s是文本改变后的内容
			// start是文本改变操作后输入光标所在位置
			// count增加内容时是增加字符的个数,删除内容时为0
			// after删除内容时是删除字符的个数,增加内容时为0
			// 通过组件索引获得的text内容是改变后的
			Log.i("onTextChanged", "onTextChanged the text's content is "+etTest.getText().toString());
			Log.i("onTextChanged", "onTextChanged the text's length is "+etTest.length());
			Log.i("onTextChanged", "onTextChanged the s is "+s);
			Log.i("onTextChanged", "onTextChanged the start is "+start);
			Log.i("onTextChanged", "onTextChanged the before is "+before);
			Log.i("onTextChanged", "onTextChanged the count is "+count);
			Log.i("onTextChanged", "-------------------------------------");
		}
		
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值