Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, I would create one text change listener, something like <code>SynchronizingWatcher</code> and attach it to both <code>EditText</code>s. Then, when you receive a text change event, before updating other text edits, just unregister old listeners, update text and enable listeners again:</p> <pre><code>class SynchronizingWatcher implements TextWatcher { Set&lt;EditText&gt; synchronizedViews = new HashSet&lt;EditText&gt;(); public void watchView(EditText view) { view.addTextChangedListener(this); synchronizedViews.add(view); } public void afterTextChanged(Editable s) { for (EditText editText : synchronizedViews) { editText.removeTextChangeListener(this); editText.setText(s); // Of course you can do something more complicated here. editText.addTextChangeListener(this); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Don't care. } public void onTextChanged(CharSequence s, int start, int before, int count) { // Don't care. } } ... // Somewhere in your activity: SyncrhonizingWatcher synchronizingWatcher = new SynchronizingWatcher(); synchronizingWatcher.watchView(myEditText1); synchronizingWatcher.watchView(myEditText1); </code></pre> <p>Another solution: provide your own <code>KeyListener</code> that <em>decorates</em> existing <code>KeyListener</code> (you can get existing key listener with <code>editText.getKeyListener()</code> and set your decorator with <code>editText.setKeyListener()</code>. Your decorator would also update other edit texts in <code>onKeyUp()</code>. But I would try to stay away from messing with that stuff.</p>
    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