zoobuffalo
Lurker
hi guys - first post whoo! 
i'm a flash developer who's just starting to learn android development. my first app is a simple kid's flash card app - basically a gallery of images with accompanying sounds. i have the gallery set up and sounds play fine. i want the gallery to shuffle to a random order on each launch. i have this working fine, using this method, which gets called in the onCreate function:
this shuffles the arrays (one which i'm passing in of the imageIds and the other is the sounds which need to maintain the same order as the images of course) - i know this isn't the best way to do this, but it works. initially. when i relaunch the app and the shuffle happens again, the images and audio don't match up, and i'm wondering why! any clues?
or better yet, i am used to using objects in flash and were this a flash movie, i'd be using objects to link the images with the sounds... anything like that exist in java that i can use instead of this messy workaround?
appreciate the help!
emma.

i'm a flash developer who's just starting to learn android development. my first app is a simple kid's flash card app - basically a gallery of images with accompanying sounds. i have the gallery set up and sounds play fine. i want the gallery to shuffle to a random order on each launch. i have this working fine, using this method, which gets called in the onCreate function:
Code:
static void shuffleArray(Integer[] ar)
{
Random rnd = new Random();
for (int i = ar.length - 1; i >= 0; i--)
{
int index = rnd.nextInt(i + 1);
// Simple swap
int a = ar[index];
int b = mSoundIds[index];
ar[index] = ar[i];
mSoundIds[index] = mSoundIds[i];
ar[i] = a;
mSoundIds[i] = b;
}
}
this shuffles the arrays (one which i'm passing in of the imageIds and the other is the sounds which need to maintain the same order as the images of course) - i know this isn't the best way to do this, but it works. initially. when i relaunch the app and the shuffle happens again, the images and audio don't match up, and i'm wondering why! any clues?
or better yet, i am used to using objects in flash and were this a flash movie, i'd be using objects to link the images with the sounds... anything like that exist in java that i can use instead of this messy workaround?
appreciate the help!
emma.