1 editText.addTextChangedListener(new TextWatcher() { 2 @Override 3 public void onTextChanged(CharSequence text, int start, int before, int count) { 4 //text 輸入框中改變后的字符串信息 5 //start 輸入框中改變后的字符串的起始位置 6 //before 輸入框中改變前的字符串的位置 默認為0 7 //count 輸入框中改變后的一共輸入字符串的數量 8 9 } 10 11 @Override 12 public void beforeTextChanged(CharSequence text, int start, int count,int after) { 13 //text 輸入框中改變前的字符串信息 14 //start 輸入框中改變前的字符串的起始位置 15 //count 輸入框中改變前后的字符串改變數量一般為0 16 //after 輸入框中改變后的字符串與起始位置的偏移量 17 18 } 19 20 @Override 21 public void afterTextChanged(Editable edit) { 22 //edit 輸入結束呈現在輸入框中的信息 23 24 } 25 });