I made a pool of about 20 strings that each display different sayings. I want one of those sayings to display to a text view on random.
I cast an integer as a random 1-20,
int randomNumber5 = (int) Math.ceil(Math.random() * 20);
and created strings named randomString1, randomString2, etc…til it hits 20.
The best way I could think to do this, was assign each string a number between 1 and 20 as a case.
So:
switch(randomNumber5){
case 1:
mTheMessage.setText(R.string.randomString1);
}
case 2:
mTheMessage.setText(R.string.randomString2);
but I feel like there is a better way to do this right?
Use an array or list.
Each element of RandomString[] is loaded with a message.