The method of realizing monitor edittext change by Android programming _android

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.