This paper illustrates the method of realizing the change of listening EditText in Android programming. Share to everyone for your reference, specific as follows:
Monitor the changes in the contents of the EditText. A setonxxxx method was not found in EditText. Baidu a bit, originally in the EditText has a method Addtextchangedlistner (Textwatcher Watcher) method, he can always monitor edittext content changes. Textwatcher is an interface class, so the abstract method in Textwatcher must be implemented:
When the contents of the EditText are changed, the Textchangedlistener event is triggered and the abstract method inside the Textwatcher is invoked.
Et_pos.addtextchangedlistener (New Textwatcher () {
@Override public
void ontextchanged (charsequence s, int Start, int before, int count) {}
@Override public
void beforetextchanged (charsequence s, int start, int count, int After) {}
@Override public
void aftertextchanged (Editable s) {
if (s.length ()!= 0) {
Clearposition.setvisibility (view.visible);
} else {
clearposition.setvisibility (view.invisible);
}
}
);
I hope this article will help you with the Android program.