title: How to prevent an infinite loop with two EditTexts?
body: <p>I have two TextViews <code>EditText</code> and have assigned each on a TextChangedListener, which reference each other, changing the text of the other textview. Specifically:</p>
  
  <pre><code>rateText.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              if(!rateText.getText().toString().equals("")) {
                  float price = Float.parseFloat(priceText.getText().toString());
                  float rate = Float.parseFloat(rateText.getText().toString());
  
                  // REFERNCES THE OTHER TEXT
                  amountText.setText(Float.toString(price / rate));
              } else {
                  amountText.setText("");
              }
          }
      });
      amountText.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              if(!rateText.getText().toString().equals("")) {
                  float price = Float.parseFloat(priceText.getText().toString());
                  float amount = Float.parseFloat(amountText.getText().toString());
  
                  // REFERNCES THE OTHER TEXT
                  rateText.setText(Float.toString(price / amount));
              } else {
                  rateText.setText("");
              }
          }
      });
  </code></pre>
  
  <p>This results in an infinite loop, because each listener causes the other one to trigger. How can i prevent this without needing a button or something?</p>