---
title: "关于EditText中的TextWatcher监听"
author: "luckldforever"
date: "2015-09-30T10:43:54Z"
tags: []
categories: ["移动开发"]
slug: "edittext-textwatcher"
draft: false
lastmod: "2015-09-25T09:49:04Z"
id: 2246088
url: "https://luckldforever.iteye.com/blog/2246088"
---

触发过程：
      1.beforeTextChange(CharSequence s,int start, int count,int after);在
        EditText里的内容即将发生变化之前触发，EditText里的内容变化有三种方式：新
        增加字符；删除字符；替换输入框中的若干个字符。无论何种变化方式，都可以理解
        为：输入框的原内容字符串S，从索引位置start开始，有count个字符即将被替换，
        替换这个count个字符的新的字符个数为after。注意：S是变化之前的输入框内容。
      2.onTextChanged(CharSequence s, int start, int before, int count);在Edit
        Text里的内容发生变化之时触发，在变化时的新的字符串S里，从索引位置start开
        始，有count个字符，是替换了原来的before个字符的。注意：S是变化之后的输入
        框内容
       3.afterTextChanged(Editable s);text变化之后触发，S是最终新的输入框的内容。