title: How to change button states in Appcelerator Titanium
body: <p>I've a series of buttons.</p>
  
  <p>Each button has 2 different states: First State, Second State. The buttons changes into alternating states with each click.</p>
  
  <p>In a scenario, if I click on Button1, it'll be in Second state. Then I click on Button2, Button2 will turn into Second State while Button1 (or any other buttons which is in the Second state) returns to the First State.</p>
  
  <p>How do I do this in Appcelerator Titanium?</p>
  
  <p>I've created the buttons like this</p>
  
  <pre><code>function createButtons(data){
  
      for (var i = 0; i &lt; data.length; i++){
          //Creating each button
          var button  = Titanium.UI.createImageView({
              image:  data[i].path,
              value: 1
          });
  
          //Adding the buttons to the center view
          centerButtons.add(button);
      }
  }
  </code></pre>
  
  <p>With each click, I'm changing the <code>value</code> of the button to either 1 or 2 to identify which state the button is in. 
  The problem is, say when I click on Button1, I can change it's value but I don't know how to detect which <strong>other</strong> button(s) is/are already in the second state so that I can reset it to it's first state?</p>