您的位置:首页 > 其它

TextWatcher参数理解

2014-11-09 00:39 316 查看

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", "-------------------------------------");
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  TextWatcher 参数