1

Generating an integer and use it as index for string array

view story
linux-howto

http://stackoverflow.com – I recently started with android programming, with just basic knowledge in java. I'm having trouble with my code,What I'm aiming is to display a randomly chosen text that's already programmed in my array after the button is clicked (onclick event). public void magicbegins() // { int min = 0; int max = 3; Random r = new Random(); int rand = r.nextInt(max - min + 1) + min; //generating random number from 0 to 3 to use as index in later event String[] magictext = {"yes", "no", "maybe"}; TextView text = (TextView) findViewById(R.id.textView1); //using the generated (HowTos)