TextWatcher基本用法

TextWatcher fieldValidatorTextWatcher = new TextWatcher() {
            @Override
            public void afterTextChanged(Editable s) { //表示最终内容
            Log.d("afterTextChanged", s.toString());
            }


            @Override
            public void beforeTextChanged(CharSequence s, int start /*开始的位置*/, int count /*被改变的旧内容数*/, int after /*改变后的内容数量*/) {
            //这里的s表示改变之前的内容,通常start和count组合,可以在s中读取本次改变字段中被改变的内容。而after表示改变后新的内容的数量。
            }


            @Override
            public void onTextChanged(CharSequence s, int start /*开始位置*/, int before /*改变前的内容数量*/, int count /*新增数*/) {
              //这里的s表示改变之后的内容,通常start和count组合,可以在s中读取本次改变字段中新的内容。而before表示被改变的内容的数量。
            }
        };

你可能感兴趣的:(TextWatcher基本用法)