Displaying string from array on screen

  • Replies:1
  • OpenNot stickiedUnanswered

Nov 20, 2012 2:48:56 PM

Hi all, fairly new to Android so I'll keep this as simple as possible. In my activity I have a set of strings (questions) stored in an array.

1String[] questions = { "question1", "question2", "question3", etc };

What I want to do is select a random string (ie question) and display it on the screen. I have tried the following code but nothing shows when I compile and run the app.

1int length = questions.length;
2for (int i = 0; i < length; i++)
3 {
4 int rand = (int) (Math.random() * length);
5 System.out.print(questions[rand]);
6 }
7 }
8}

Nov 27, 2012 3:03:03 PM

Over a week and not one response for such a simple query... hmmm! It's strange how there seems to be so many Android developers out there yet I can't get as much as one response for probably one of the most simple questions ever asked about Android development.

I'm beginning to think there are no real developers out there and that everyone just resorts to using third-party creation tools such as Andromo and Appsgeyser. Surely there must be one developer out there who knows how to retrieve information from a string array and display it on the screen?? How hard can it be??