android.text.TextWatcher
2016-02-29 11:21
309 查看
/** * When an object of a type is attached to an Editable, its methods will * be called when the text is changed. */ public interface TextWatcher extends NoCopySpan { /** * This method is called to notify you that, within <code>s</code>, * the <code>count</code> characters beginning at <code>start</code> * are about to be replaced by new text with length <code>after</code>. * It is an error to attempt to make changes to <code>s</code> from * this callback. */ public void beforeTextChanged(CharSequence s, int start, int count, int after); /** * This method is called to notify you that, within <code>s</code>, * the <code>count</code> characters beginning at <code>start</code> * have just replaced old text that had length <code>before</code>. * It is an error to attempt to make changes to <code>s</code> from * this callback. */ public void onTextChanged(CharSequence s, int start, int before, int count); /** * This method is called to notify you that, somewhere within * <code>s</code>, the text has been changed. * It is legitimate to make further changes to <code>s</code> from * this callback, but be careful not to get yourself into an infinite * loop, because any changes you make will cause this method to be * called again recursively. * (You are not told where the change took place because other * afterTextChanged() methods may already have made other changes * and invalidated the offsets. But if you need to know here, * you can use {@link Spannable#setSpan} in {@link #onTextChanged} * to mark your place and then look up from here where the span * ended up. */ public void afterTextChanged(Editable s); }说明:
public void beforeTextChanged(CharSequence s, int start, int count, int after)
s改变前的text字符,start当前起始位置,count被替换字符的长度(删除时为0),after新替代字符的长度
public void onTextChanged(CharSequence s, int start, int before, int count)
s改变后的text字符,start替换前的起始位置(同beforeTextChanged),before被替换字符的长度,count新替代字符的长度
public void afterTextChanged(Editable s)
s改变后的text字符
相关文章推荐
- Android ScrollView向上滑动控件顶部悬浮效果实现
- 如何让android studio在运行时自带签名
- Android Studio使用Gradle上传到jCenter
- 4.18.2 android实现断点续传
- Android-spinner
- Android管理与操作Wifi简单实例源码
- Android.mk具体解释
- Android— AndroidStudio如何给log添加过滤项(Filters
- android图片压缩总结
- ZZAndroid客户端性能优化----魅族资深工程师毫无保留奉献
- android 之自定义属性1
- android学习之LinearLayout
- Android:设置背景色以及theme(主题)设置(一)
- Android Surface相关常见问题
- 初学Android,图形图像之使用Bitmap和BitmapFactory(二十四)
- Android开发之机顶盒上gridview和ScrollView的使用详解
- Android Studio常用插件
- 解决Android adb端口被占用的问题
- Android SearchView 实现一边输入一边搜索功能
- Android 高效加载大图片