Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>TextWatcher should work just fine you only need to initialize the listener once, so in your <strong><em>onCrateView()</em></strong> in an Activity. Also like @Arash said use <strong><em>.equals(CharSequence c)</em></strong> instead of the <strong>==</strong> operand. Other than that hopefully your question is answered.</p> <pre><code>final TextView myText = (TextView)findViewById(R.id.my_Text); EditText myEdit = (EditText)findViewById(R.id.my_Edit); myEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {} @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { if(!TextUtils.isEmpty(charSequence) &amp;&amp; myText.equals(charSequence)) { // Do something with myText } } @Override public void afterTextChanged(Editable editable) { } }); </code></pre> <p><strong>EDIT</strong></p> <p>After seeing your full code this line:</p> <pre><code>final String matchString = myEdit.getText().toString(); </code></pre> <p>This String will be empty therefore it will never evaluate the statement. Its blank because the user has never input anything. Say you wanted to match the string "Hello" you would do this:</p> <pre><code>public void textChangeMethod() { final TextView myText = (TextView)findViewById(R.id.my_Text); EditText myEdit = (EditText)findViewById(R.id.my_Edit); final String matchString = "Hello"; TextWatcher filterTextWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count,int after) {} @Override public void onTextChanged(CharSequence s,int i, int i2,int i3) { if(!TextUtils.isEmpty(s) &amp;&amp; matchString.equals(s)){ myText.setText("Finished"); } } @Override public void afterTextChanged(Editable arg0) {} }; myEdit.addTextChangedListener(filterTextWatcher); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload