Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can add more images in array list in android

Tags:

android

I am starting to game development adding bitmap images in to array list how can implemented

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

Given 9 images are storing array list display random order how can implemented its urgent

like image 748
Narasimha Avatar asked Jan 01 '26 07:01

Narasimha


1 Answers

There are a number of ways you can achieve what you are attempting to achieve. One such way is to ditch 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
    //...
}
like image 65
nEx.Software Avatar answered Jan 03 '26 21:01

nEx.Software



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!