android EditText输入变化事件

 1 editText.addTextChangedListener(new TextWatcher(){
 2 
 3    public void afterTextChanged(Editable s) {
 4     // TODO Auto-generated method stub
 5     //s:变化后的所有字符
 6     Toast.makeText(getApplicationContext(), "变化:"+s, Toast.LENGTH_SHORT).show();
 7    }
 8 
 9    public void beforeTextChanged(CharSequence s, int start, int count,
10      int after) {
11     // TODO Auto-generated method stub
12     //s:变化前的所有字符; start:字符开始的位置; count:变化前的总字节数;after:变化后的字节数
13     Toast.makeText(getApplicationContext(), "变化前:"+s+";"+start+";"+count+";"+after, Toast.LENGTH_SHORT).show();
14    }
15 
16    public void onTextChanged(CharSequence s, int start, int before,
17      int count) {
18     // TODO Auto-generated method stub
19     //S:变化后的所有字符;start:字符起始的位置;before: 变化之前的总字节数;count:变化后的字节数
20     Toast.makeText(getApplicationContext(), "变化后:"+s+";"+start+";"+before+";"+count, Toast.LENGTH_SHORT).show();
21    }
22 });

 

posted @ 2015-03-18 11:45  种花小哥  阅读(1190)  评论(0编辑  收藏  举报