TextWatcher基本用法
生活随笔
收集整理的這篇文章主要介紹了
TextWatcher基本用法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
editText.addTextChangedListener(new TextWatcher() {/*** 內(nèi)容改變前調(diào)用* 原有的文本s中,從start開始的count個(gè)字符將會(huì)被一個(gè)新的長(zhǎng)度為after的文本替換,注意這里是將被替換,還沒有被替換* @param s* @param start* @param count* @param after*/@Overridepublic void beforeTextChanged(CharSequence s, int start, int count, int after) {Log.i("beforeTextChanged",s+"********"+start+"*******"+count+"****"+after);}/*** 內(nèi)容改變過程中調(diào)用* 原有的文本s中,從start開始的count個(gè)字符替換長(zhǎng)度為before的舊文本,注意這里沒有將要之類的字眼,也就是說一句執(zhí)行了替換動(dòng)作* @param s* @param start* @param before* @param count*/@Overridepublic void onTextChanged(CharSequence s, int start, int before, int count) {Log.i("onTextChanged",s+"********"+start+"****"+before+"*******"+count);}/*** 內(nèi)容改變后調(diào)用* @param s 最終內(nèi)容*/@Overridepublic void afterTextChanged(Editable s) {Log.i("afterTextChanged",s.toString());}});
?
轉(zhuǎn)載于:https://www.cnblogs.com/butterfly-clover/p/5145451.html
總結(jié)
以上是生活随笔為你收集整理的TextWatcher基本用法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [css] 使用css写一个垂直翻转图
- 下一篇: [css] 举例说明clear取值有哪