• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with string-arrays

__Jon__

Newbie
Hi. I have a question about how to get the XML string array items into a Java string[] array.

This is what I have:
Code:
private String[] rbarray;
private Random random;
...
...
...
rbarray =res.getStringArray(R.array.Questions);
randint = random.nextInt(2);//so far I only have two items in the strin-array
String question = rbarray[randint];
QuesView.setText(question);

This seems correct. When I try to run this in the emulator I get an error dialog. Take this out and run a simple "QuesView.setText("any old string") and it runs.

I tried to debug it. I have to say I can't get my head around the debugger. I couldn't see an error message or stack trace anywhere.

A long time ago I used to use Textpad to do all my Java (which wasn't very much). If it had an error, I looked at the stack trace and fixed it. Anyway, rant over, can anyone give me a hint why this doesn't work?
 
Ummm... I seem to have solved it alone (with the help of this thread:
HTML:
http://stackoverflow.com/questions/2717614/show-random-string
)

I forgot to getResources:(. Stupid mistake.
 
Back
Top Bottom