android API之android.text.TextWatcher
When an object of a type is attached to an Editable, its methods will be called when the text is changed.
接口TextWatcher定义了三个抽象方法:
public 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
. It is an error to attempt to make changes to s
from this callback.
public 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
. It is an error to attempt to make changes to s
from this callback.
public void afterTextChanged(Editable s)
This method is called to notify you that, somewhere within s
, the text has been changed. It is legitimate(合理) to make further changes to s
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 Spannable.setSpan
in onTextChanged
to mark your place and then look up from here where the span ended up.
相关文章
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 8
- Android API之android.content.BroadcastReceiver
- Android API之android.provider.ContactsContract
- Android API之android.os.Parcelable
- macos安装android studio(Android Studio 2021.1.1)
- Android NFC开发(一)——初探NFC,了解当前前沿技术
- 申请google android map api key
- Android开发学习---template requires a minimum SDK version of at least 7,build target API version of 14
- 1、Android Studio集成极光推送(Jpush) 报错 java.lang.UnsatisfiedLinkError: cn.jpush.android.service.PushProtoco
- Android 中文 API (26) —— SeekBar
- 【VLC-Android】vlc-android简例
- 【Android】android镜像翻转
- macos安装android studio(Android Studio 2021.1.1)
- Android 使用 Volley 实现网络请求
- Android 个人界面的布局
- Android 12.0 屏蔽FallbackHome机制去掉android正在启动直接进入默认Launcher功能实现
- Android 9.0 延时开机动画解决首次开机黑屏和去掉android正在启动的提示框
- Android 10.0 SystemUI 下拉通知栏每条通知去掉灰色的背景
- 【Android 进程保活】oom_adj 值 ( 简介 | 查询进程 PID | 根据进程 PID 查询 oom_adj 值 )
- 【Android 安全】DEX 加密 ( 阶段总结 | 主应用 | 代理 Application | Java 工具 | 代码示例 ) ★
- Android 在非主线程无法操作UI意识
- Android多媒体开发-- android中OpenMax的实现整体框架
- Android - 控件android:ems属性
- 使用Android Studio build tensorflow/examples/android——直接用android studio即可
- Android应用开发全程实录
- Android JNI常用api