title: Image button in android pressed and get a random image in an array sequentially
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public abstract class MainActivity extends Activity  implements View.OnClickListener{
  
      private ImageButton bt1;
      public int index =0;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          final Drawable[][] images = new Drawable[4][16];
          bt1 = (ImageButton) findViewById(R.id.im_bt1);
          bt1.setImageDrawable(images[index][(int)(Math.random()*16)]);
          bt1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  index++;
                  ((ImageButton)v).setImageDrawable(images[index][(int)(Math.random()*16)]);
  
              }
          });
  
      }
  
  
      Red RR1 = new Red(R.drawable.rr1);
      Red RY1 = new Red(R.drawable.ry1);
      Red RG1 = new Red(R.drawable.rg1);
      Red RB1 = new Red(R.drawable.rb1);
      Green GB1 = new Green(R.drawable.greenblue);
      Green GG1 = new Green(R.drawable.greengreen);
      Green GR1 = new Green(R.drawable.greenred);
      Green GY1 = new Green(R.drawable.greenyellow);
      Yellow YY1 = new Yellow(R.drawable.yellowyellow);
      Yellow YB1 = new Yellow(R.drawable.yellowblue);
      Yellow YG1 = new Yellow(R.drawable.yellowgreen);
      Yellow YR1 = new Yellow(R.drawable.yellowred);
      Blue BR1= new Blue(R.drawable.br1);
      Blue BB1=new Blue(R.drawable.bb1);
      Blue BY1=new Blue(R.drawable.by1);
      Blue BG1= new Blue(R.drawable.bg1);
  
      Red[] Redarray = new Red[]{
              RR1,RY1,RG1,RB1
      };
      Green[] Greenarray = new  Green[]{
              GR1,GB1,GY1,GG1
      };
  
      Blue[] Bluearray = new  Blue[]{
        BB1,BY1,BG1,BR1
      };
  
      Yellow[] Yellowarray = new Yellow[]{
              YB1,YG1,YR1,YY1
      };
  
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have an <code>ImageButton</code> in my layout and I want to press the button and get another random <code>ImageButton</code> from an array and the get another when I press that one, but I want it to show sequentially on the arrays that I made.</p>
  
  <p>array of images 1
  array of images 2
  array of images 3
  array of images 4</p>
  
  <p>Image Button from <code>array1</code> to another random Image Button from <code>array2</code>  to another Image Button from <code>array 3</code>...</p>
  
  <p>edit: so I made a class of all the arrays and it's not working.. I'm struggling to make an array of arrays.. can u guys check my code? thanks..</p>