Android中的TextWatcher的使用
来源:互联网 发布:下载blued交友软件 编辑:程序博客网 时间:2024/05/22 09:48
先介绍TextWatcher
TextWatcher fieldValidatorTextWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) {//表示最终内容 Log.d("afterTextChanged", s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start/*开始的位置*/, int count/*被改变的旧内容数*/, int after/*改变后的内容数量*/) { //这里的s表示改变之前的内容,通常start和count组合,可以在s中读取本次改变字段中被改变的内容。而after表示改变后新的内容的数量。 } @Override public void onTextChanged(CharSequence s, int start/*开始位置*/, int before/*改变前的内容数量*/, int count/*新增数*/) { //这里的s表示改变之后的内容,通常start和count组合,可以在s中读取本次改变字段中新的内容。而before表示被改变的内容的数量。 } };
使用 :
mEditStatus.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { int count = 140 - mEditStatus.length(); mTextCount.setText(Integer.toString(count)); mTextCount.setTextColor(Color.GREEN); if (count < 10) mTextCount.setTextColor(Color.YELLOW); else if (count < 0) mTextCount.setTextColor(Color.RED); } });
0 0
- Android中的TextWatcher的使用
- android中的TextWatcher的应用
- android的TextView的TextWatcher使用
- Android - TextWatcher监听事件的使用
- Android TextWatcher使用详解
- TextWatcher的使用
- TextWatcher的使用
- Android使用TextWatcher匹配email造成ANR的解决
- android edittext textwatcher的用法
- android之TextWatcher的监听
- OnEditorActionListener与TextWatcher 的使用
- androidの监听EditView中的文本TextWatcher
- android EditText 中的TextWatcher 限制小数点位数
- android TextWatcher
- Android TextWatcher
- Android TextWatcher监控EditText字数的改变
- EditText实时监听TextWatcher的使用
- Android EditText 共用TextWatcher,在TextWatcher中确定对应的被观察对象
- 02 微信获取accestoken
- 集合
- Android中的EditText失去和得到焦点时的事件响应
- 泛型
- 急需解决的问题
- Android中的TextWatcher的使用
- IEEE CSO 2009 修订版论文要求
- 云服务器初始化
- mac安装mysql的两种方法(含配置)
- IEEE会议论文模板IEEE Manuscript Templates for Conference Proceedings
- centos下用yum方式配置MySQL
- java算术表达式求值-中缀表达式转后缀表达式
- ubuntu16.04安装oracle11g
- Linux下配置两个或多个Tomcat启动