Textwatcher The use of monitoring events
This address: Http://blog.csdn.net/caroline_wendy
Textwatcher can listen for input fonts in EditText , overriding 3 methods:beforettextchanged (), ontextchanged (), Aftertextchanged (); You can add anonymous inner classes in the EditText Addtextchangedlistener by using the following methods:
Meditstatus.addtextchangedlistener (New Textwatcher () { @Override public void Beforetextchanged ( charsequence s, int start, int count, int after) { } @Override public void ontextchanged (charsequence s, int s Tart, int before, int count) { } @Override public void aftertextchanged (Editable s) { int count = 140-me Ditstatus.length (); Mtextcount.settext (Integer.tostring (count)); Mtextcount.settextcolor (color.green); if (Count < ten) Mtextcount.settextcolor (color.yellow); else if (Count < 0) Mtextcount.settextcolor (color.red); } });
Android-textwatcher the use of monitoring events