title: Code isn't starting a random activity - Android/Java
body: <p>I have written some code to try and make a random activity start. I will post the code below:</p>
  
  <pre><code>private void setupMusicQuestion() {
          ImageButton musicquestion = (ImageButton)      findViewById(R.id.imageButton2);
  
          musicquestion.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                  int min = 1;
                  int max = 10;
                  ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
                  for(int i = min; i &lt;= max; i++) list.add(i);
                  Collections.shuffle(list);
  
                  Integer x = list.get(0);
  
  
                  switch(x){
                   case 1:
                       startActivity(new Intent(SecondActivity.this, MusicOne.class));
                    break;
                   case 2:
                       startActivity(new Intent(SecondActivity.this, MusicTwo.class));
                    break;
                   case 3:
                       startActivity(new Intent(SecondActivity.this, MusicThree.class));
                    break;
                   case 4:
                       startActivity(new Intent(SecondActivity.this, MusicFour.class));
                    break;
                   case 5:
                       startActivity(new Intent(SecondActivity.this, MusicFive.class));
                    break;
                   case 6:
                       startActivity(new Intent(SecondActivity.this, MusicSix.class));
                    break;
                   case 7:
                       startActivity(new Intent(SecondActivity.this, MusicSeven.class));
                    break;
                   case 8:
                       startActivity(new Intent(SecondActivity.this, MusicEight.class));
                    break;
                   case 9:
                       startActivity(new Intent(SecondActivity.this, MusicNine.class));
                    break;
                   case 10:
                       startActivity(new Intent(SecondActivity.this, MusicTen.class));
                    break;
                   }
  </code></pre>
  
  <p>However, when I run this program it always loads up the activity in position 1. Can you see why this is?</p>
  
  <p>Thanks in advance!</p>