Android edittext listening (addtextchangedlistener)

Source: Internet
Author: User
Http://houwanji.blog.163.com/blog/static/162276220104140141050/

Paste the Code directly.
_ OK. setclickable (false); // initialization cannot be clicked
_ OK. setenabled (false );
_ Edit = (edittext) findviewbyid (R. Id. fb_status_eidt );
// Mainly refers to the implementation of interfaces in the listener
_ Edit. addtextchangedlistener
(New textwatcher (){
@ Override
Public void aftertextchanged
(Editable s ){
// Todo auto-generated method stub

}

@ Override
Public void beforetextchanged
(Charsequence S, int start, int count,
Int after ){
// Todo auto-generated method stub

}

@ Override
Public void ontextchanged
(Charsequence S, int start, int before,
Int count ){
// Todo auto-generated method stub
// The Key is here, listening for the input string. If it is greater than zero, you can click Enable.
If (S. Length ()> 0 ){
_ OK. setclickable (true );
_ OK. setenabled (true );
} Else {
_ OK. setclickable (false );
_ OK. setenabled (false );
}
}
});

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.