Android EditText文本内容变化监听方法
package com.google; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; public class ActMain extends Activity { private EditText et_search; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); et_search = (EditText) findViewById(R.id.et_search); et_search.addTextChangedListener(textWatcher); } private TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // System.out.println("-1-onTextChanged-->" + et_search.getText().toString() + "<--"); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // System.out.println("-2-beforeTextChanged-->" + et_search.getText().toString() + "<--"); } @Override public void afterTextChanged(Editable s) { // System.out.println("-3-afterTextChanged-->" + et_search.getText().toString() + "<--"); } }; }