Hi,
Kristopher is correct.
Actually i wanted to display images one by one randomly.
I tried with random but doesn't work.
but I was able to do that by using Array List and shuffle.collections.
first I added max number of images into array list and shuffled it.
Then I got shuffled numbers one by
Assuming that you have a rand() function (that might repeat) and that
your value range is [0, maxValue - 1]: Create an array of size
maxValue and initialize everything to its index:
for (int i = 0; i maxValue; ++i) {
arr[i] = i;
}
Now do this:
for (int i = 0; i maxValue - 1; ++i) {
tmp =
why should the number not appear again? It's random, remember? Or do you
mean pseudo-random?
What number range are you looking at?
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to
It sounds like what you might to do is actually generate a random list of
numbers and display them one by one. Is that the case?
I can imagine a number of situations where it would be useful: a keno game,
shuffling a deck of cards, or something like that. (In this case, it could
be an Android
There are random number generators in Java (java.util.Random) and in
the crypto support. Or you can dig up a reference and write your
own. Or you can use the millisecond bits of the system clock.
If you use a good pseudo-random generator (and I assume that
java.util.Random is reasonably good)
5 matches
Mail list logo