Android to implement button click events by listening EditText

Source: Internet
Author: User

If you don't have access to a third-party input device, click the button and then just find your buttons and then:

Button.performclick ();

You can do it.


So if you use a third-party input method, there are times when listening is not so easy:

The following scenarios are:

External input service, just throw me a string of characters, I get the character after the Execute button event

The code is as follows:

  edittext1.addtextchangedlistener (New textwatcher () {              @Override              public void aftertextchanged (editable s)  {                 LOG.D (tag,  "aftertextchanged");             }              @Override             public  void beforetextchanged (charsequence s, int start, int count,                                             int&nBsp;after)  {                 LOG.D (tag,  "beforetextchanged:"  + s +  "-"  + start +  "-"  + count +  "-"  + after);             }             @Override              public void ontextchanged ( charsequence s, int start, int before,                                        int count)  {                 if (S.length () >5)  {                    LOG.D (TAG,  " OnTextChanged: " + s + "-" + "-" + start + "-" +  before +  "-"  + count);                                     toast.maketext (context, s +  "",  Toast.LENGTH_LONG). Show ();//                     EditText editText3 =  (EditText)  findviewbyid (r.id.et_3);                      Button button =  (Button)  findviewbyid (r.id.bu_1);             &nBsp;       button.performclick ();                 }             }        });

It is important to note that

OnTextChanged

Method must give a qualified parameter, otherwise it will continue to execute, forming a dead loop, the program will exit unexpectedly.

I'm writing it here.

if (S.length () >5)


Android to implement button click events by listening EditText

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.