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.

android API之android.text.TextWatcher的更多相关文章

  1. 【Android API】Android 4.1 API官方文档详解

    原文:http://android.eoe.cn/topic/summary 翻译:[eoeAndroid原创团队]kris.流风而逝.贼寇在何方.snowxwyo.lsy4833406 更新日期:2 ...

  2. Android API之android.content.BroadcastReceiver

    android.content.BroadcastReceiver Base class for code that will receive intents sent by sendBroadcas ...

  3. Android API之android.provider.ContactsContract.RawContacts

    android.provider.ContactsContract.RawContacts Constants for the raw contacts table, which contains o ...

  4. Android API之android.provider.ContactsContract

    android.provider.ContactsContract ContactsContract是联系人provider和app的contract.定义了已支持的URL和column.取代了之前的 ...

  5. Android API之android.os.Parcelable

    android.os.Parcelable Interface for classes whose instances can be written to and restored from a Pa ...

  6. Android API之android.os.AsyncTask

    android.os.AsyncTask<Params, Progress, Result> AsyncTask enables proper and easy use of the UI ...

  7. Android API之android.widget.Filterable

      android.widget.Filterable 定义了一种可过滤的行为.Filterable接口通常有android.widget.Adapter来实现.接口Filterable中有个抽象方法 ...

  8. Android API之android.content.AsyncQueryHandler

    android.content.AsyncQueryHandler A helper class to help make handling asynchronous ContentResolver ...

  9. Android API之android.provider.ContactsContract.Data

    android.provider.ContactsContract.Data Constants for the data table, which contains data points tied ...

随机推荐

  1. bt z

    比特币从2008年开始启动,到09年创始区块的出现,甚至一直到10年和11年都只是中本聪自己一个人在运行这套程序.在早期这个极少数人参与到游戏里,大家运行一个软件,这个软件既是钱包也是挖矿软件,进行P ...

  2. [java web 入门](一)MyEclipse &amp; HelloWorld 记录

    第一部,下载安装MyEclipse for mac. http://downloads.myeclipseide.com/downloads/products/eworkbench/2014/inst ...

  3. joel 相关

    1. stack overflow , http://blog.jobbole.com/102810/, stack overflow 提问也是一门学问. 2. tello 类似于 leangoo,一 ...

  4. [翻译] Haneke(处理图片缓存问题)

    Haneke https://github.com/hpique/Haneke A lightweight zero-config image cache for iOS. 轻量级0配置图片缓存. H ...

  5. Git 学习(七)标签管理

    Git 学习(七)标签管理 发布版本时,通常会先在版本库中打一个标签,这样,就唯一确定了打标签时刻的版本.取出某个标签的版本,就是把那个打标签的时刻的历史版本取出来.所以,标签也是版本库的一个快照. ...

  6. 【BZOJ】【2120】数颜色 & 【2453】维护队列

    莫队算法 分块大法吼 这题乍一看跟HH的项链很像啊……只是多了一个修改操作……然而我就不会做了

  7. Linux监听进程是否存在,并加入定时任务

    前言 我们在linux主机上可能需要一直运行某一服务,如果关机后或者误杀,使得服务停止,从而影响日常的任务.比如一BI项目数据库的抽取,使用Taskctl调度,在每天固定时间进行数据的抽取,如果主机上 ...

  8. 手机WiFi万能钥匙查看破解的password和手机查询命令收集

    手机须要网络利用WiFi万能钥匙破解了WIFI的password.手机就能够上网了,但假设想在电脑上使用手机破解的Wifi热点上网就须要password,此时须要知道手机破解的password,WiF ...

  9. Android -- ViewPager放入多个XML监听每个的控件

    我这这里就用了两个imageButton的监听器,两个XML上分别一个. 昨天做了个Viewpager,今天想试试在上面弄上Button试试,结果,弄不来,然后查文档,没查到...百度了1个多小时才出 ...

  10. NGUI诡异的drawCall

    看了很多关于NGUI drawCall的文章,见得比较多的一个观点是:一个 Atlas 对应一个Drawcall. 好奇心下做了个demo,两个panel中只用到一个Atlas,却产生了10个draw ...