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 });