How to add more images to the list of arrays in android

I'm starting the development of the game by adding bitmaps to the list of arrays, how can I implement

for(int i =0;i<9;i++)
{
  resizedBitmap[i] = Bitmap.createBitmap(bitmapOrg, (i%3)*newWidth, (i/3)*newHeight,newWidth, newHeight);            
}

Given that 9 images store the display of the list of arrays in random order, how can I implement its urgent

+3
source share
1 answer

There are several ways to achieve what you are trying to achieve. One such way is to cut out the array and use an ArrayList instead.

ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>(9);
for (int i = 0; i < 9; i++)
{
    mBitmaps.add(Bitmap.createBitmap(bitmapOrg, (i % 3) * newWidth, (i / 3) * newHeight, newWidth, newHeight));
}

Collections.shuffle(mBitmaps);

for (int i = 0; i < 9; i++)
{
    Bitmap bitmap = mBitmaps.get(i));

    //Do something
    //...
}
+2
source

Source: https://habr.com/ru/post/1770903/


All Articles