ALi
ALi

Reputation: 428

how to start Activty randomly in Android

i want to implement simple game. In game there are only three pictures which will displayed to gesture on it. but i need to start game each time with different pictures.

Means if first time i play the game. it will show 2nd image to draw, then 1st to draw to draw, then third to draw. Game End

if i play game 2nd time. order of images should be changed.

Any guide ...

Thanks

Upvotes: 0

Views: 51

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234857

In onCreate, load your three images into an ArrayList and then call Collections.shuffle(imageList). Then use the first image in the array. If you don't want to do all the work of loading the images, use an ArrayList of the image resource IDs.

Upvotes: 1

Related Questions