[android-developers] Re: Unique Random numbers

2011-03-30 Thread Hassy
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

[android-developers] Re: Unique Random numbers

2011-03-29 Thread Aisthesis
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 =

[android-developers] Re: Unique Random numbers

2011-03-28 Thread lbendlin
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

Re: [android-developers] Re: Unique Random numbers

2011-03-28 Thread Kristopher Micinski
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

[android-developers] Re: Unique Random numbers

2011-03-28 Thread DanH
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)