title: Shuffling images with buttons matching the shuffle
body: <p>I am trying to layout 10 image buttons numbered 1-10 randomly on screen. 
  I used an <strong>array list and Collections</strong>. Shuffle command to shuffle the background <code>drawables</code>.<br>
  But I cant seem to tie the button listeners to these random images.</p>
  
  <pre><code>// assigned arrays here
  Button[] buttons = new Button[10];
  Button[] buttonimages = new Button[10];
  List&lt;Button&gt; list;
  // Global Variables
  int[] buttonarray =     {R.drawable.button1,R.drawable.button2,R.drawable.button3,R.drawable.button4,R.drawable.button5,R.drawable.button6,R.drawable.button7,R.drawable.button8,R.drawable.button9,R.drawable.button10};
  int idarray[] = {R.id.number1,R.id.number2,R.id.number3,R.id.number4,R.id.number5,R.id.number6,R.id.number7,R.id.number8,R.id.number9,R.id.number10};
  </code></pre>
  
  <p>// then I add to arraylist and shuffle</p>
  
  <pre><code>public void randomnumbers2() {
  
      for (int z=0;z&lt;10;z++) {
          buttons[z] = (Button)findViewById(idarray[z]);
      }
      for (int k=0;k&lt;10;k++) {
          buttonimages[k] = (Button)findViewById(buttonarray[k]);
      }
      list = new ArrayList&lt;Button&gt;(10);
      for(int i = 0; i &lt; 10; i++) list.add(buttons[i]);
      Collections.shuffle(list);
  
      for (int z=0;z&lt;10;z++) {
          buttons[z] = (Button)findViewById(idarray[z]);
      }
  
      for (int j=0;j&lt;10;j++){
          Button b1 = (Button) findViewById(idarray[j]);
          ((Button) list.set(j, buttons[j])).setBackgroundResource(buttonarray[j]);
      }
  }       
  </code></pre>
  
  <p>But my buttons are defined like this:
  setup  buttons</p>
  
  <pre><code>    button1 = (Button) findViewById(R.id.number1);
      button2 = (Button) findViewById(R.id.number2);
      button3 = (Button) findViewById(R.id.number3);
      button4 = (Button) findViewById(R.id.number4);
      button5 = (Button) findViewById(R.id.number5);
      button6 = (Button) findViewById(R.id.number6);
      button7 = (Button) findViewById(R.id.number7);
      button8 = (Button) findViewById(R.id.number8);
      button9 = (Button) findViewById(R.id.number9);
      button10 = (Button) findViewById(R.id.number10);
  </code></pre>
  
  <p>Problem is, 
  when I click the first button. It has an image of number 5, in the 1st position, but its still associated with button #1. Basically I have 2 rows of 5 numbers mixed up. I want the button click to respond to button 5, not button1.</p>