Thursday, April 28, 2011

Generate random numbers in Android app

Sometimes creating a series of random numbers in an Android app can be handy.

Create an object from the Random class. An example of this would be:

Random myNumber = new Random();

Then, just add your new object to your text field. Don't forget to add .nextInt to the end. Between your function's parentheses, add the number of random numbers you want in your range. For instance, if you choose the number 5, it will actually choose 6 because it starts at 0.

Interested in World War II? Download my WWII trivia game for iPhone- CODENAME:Trivia WW2

No comments:

Post a Comment