title: Android: set multiple button selection onClick
body: <p>I have a set of buttons:</p>
  
  <pre><code>[Button1]
  [Button2]
  [Button3]
  [Button4]
  [Button5]
  [Button6]
  </code></pre>
  
  <p>All of which share the same onClick method: </p>
  
  <pre><code>b.setOnClickListener(new OnClickListener() {
  
      @Override
      public void onClick(View v) {
          Button b = (Button) v;
          Button comp;
          int i = b.getId();
          selected[i] = !selected[i];
          b.setSelected(selected[i]);
          for (int j = 0; j &lt; 6; j++) {
              if (i != j) {
                  selected[j] = false;
                  comp = lifestyleButtonArray.get(j);
  
                  if(comp.isSelected())
                      comp.setSelected(selected[j]);
                      Log.w(TAG,"[Button] selection for button #"+j+"="+selected[j]);
  
              }
          }
      }
  });
  </code></pre>
  
  <p>The first part of the onClick method works as expected. When a button is clicked, toggle the buttons 'selection' value to change the color of the button  (defined in a drawable xml file) and then de-select all other buttons, so that at most one button is marked 'selected' at a time.</p>
  
  <p>The selection part works, but the buttons are not re-drawn with the appropriate color, so it appears that two buttons are selected!</p>
  
  <p>I have tried invalidate and requestLayout, but that didn't help. Any suggestions?</p>
  
  <p><strong>EDIT:</strong> After giving this some more thought, the real question to be asked here is: </p>
  
  <p>How do I update a view that is not the view from the onClick method? </p>
  
  <p>In my example, when I select button1 I want to be able to remove the selection from buttons 2-6, but since buttons 2-6 are not the view being called, they show the correct selected value (that they are unselected) but do not update their UI view to the 'non-selected' color!</p>