- 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 () + "<--");
- }
- };
- }
Android Application Development edittext text content change Monitoring method