title: Android onTextChanged for two EditTexts, do I use an array?
body: <p>I have 2 editText's and I want to handle both inputs with onTextChanged, can I do this with an array if so how, I dont see how I can do it without using arrays. OK, this is the update on what I have.</p>
  
  <pre><code>    public class AlphaActivity extends Activity {
  
  private static final String TO_BOX = "TO_BOX";
  private static final String FROM_BOX = "FROM_BOX";
  //  private String updateGuess;
  //  private String update_label;
  
  private int guess, theFirst, theLast;
  //private int count;
  
  private String update_text;
  
  EditText firstText;
  EditText secondText;
  
  TextView updateLabel;
  
  Button tooHighButton;
  Button tooLowButton;
  Button correctButton;
  Button newGameButton;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_alpha);
  
      if(savedInstanceState == null){
          // Just started
          theFirst = 0;
          theLast = 100; 
      } 
      else
      {
          // App is being restored
          theFirst = savedInstanceState.getInt(TO_BOX);
          theLast = savedInstanceState.getInt(FROM_BOX); 
      }
  
      //fromBox   = (EditText) findViewById(R.id.firstText);
      //toBox = (EditText) findViewById(R.id.secondText);
  
      //fromBox.addTextChangedListener(fromBox);
      //toBox.addTextChangedListener(toBox);
  
  
      updateLabel = (TextView)findViewById(R.id.updateText);
  
      firstText   = (EditText)findViewById(R.id.firstText);
      firstText.addTextChangedListener(fromBoxListener);
  
      secondText  = (EditText)findViewById(R.id.secondText);
      secondText.addTextChangedListener(fromBoxListener);
  
      tooHighButton = (Button)findViewById(R.id.guiTooHigh);
      tooLowButton = (Button)findViewById(R.id.tooLowGui);
      correctButton = (Button)findViewById(R.id.correctGui);
  
      setButtonOnClickListeners();
  
  }
  
  
  
  private TextWatcher fromBoxListener = new TextWatcher()
  {
  
      @Override
      public void afterTextChanged(Editable arg0) {
          // 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
  
          try
          {
              //theFirst = Integer.parseInt(s.toString());
              theFirst = Integer.parseInt(firstText.getText().toString());
              theLast = Integer.parseInt(secondText.getText().toString());
  
              if (theFirst &gt; theLast)
              {
                  updateLabel.setText("You must flip your integers"); 
              }
              else if (theFirst &lt; 0)
              {
                  updateLabel.setText("You cannot enter a negative number!"); 
  
              }
  
              guess = (theFirst + theLast) / 2;
              updateLabel.setText("Did you think of " + guess + " ?");
  
          } catch (NumberFormatException nfe)
          {
              updateLabel.setText("You must enter an integer! ");
          }
  
          //updateLabel();
  
      }
  
  };
  
  
  
  private void setButtonOnClickListeners(){
  
      tooHighButton.setOnClickListener(new OnClickListener(){
  
          public void onClick(View arg0) {
  
              theLast = (guess - 1);
              guess = (theFirst + theLast) / 2;
  
              if (theFirst &lt; theLast)
              {
                  secondText.setText("" + theLast);
                  updateLabel.setText("Did you think of " + guess + " ?");
                  //count++;
              } else if (theFirst &gt; theLast)
              {
                  updateLabel.setText("It appears you changed your number!");
              } else
              {
                  updateLabel.setText("Did you think of " + guess + " ?");
              }
  
  
  
          }
      });
  
      tooLowButton.setOnClickListener(new OnClickListener(){
  
          @Override
          public void onClick(View arg0) {
  
              theFirst = (guess + 1);
              guess = (theFirst + theLast) / 2;
  
              if (theFirst &lt; theLast)
              {
                  firstText.setText("" + theFirst);
                  updateLabel.setText("Did you think of " + guess + " ?");
                  //count++;
              } else if (theFirst &gt; theLast)
              {
                  updateLabel.setText("It appears you changed your number!");
              } else
              {
                  updateLabel.setText("Did you think of " + guess + " ?");
              }   
  
          }       
      });
  
  
      correctButton.setOnClickListener(new OnClickListener(){
  
          @Override
          public void onClick(View arg0) {
              updateLabel.setText("Thank you for playing this game!");
          }
  
      });
  
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.alpha, menu);
      return true;
  }
  </code></pre>
  
  <p>}</p>