1. Are you ready for the Galaxy S20? Here is everything we know so far!

Help with string-arrays

Discussion in 'Android Development' started by __Jon__, Aug 18, 2010.

  1. __Jon__

    __Jon__ Newbie
    Thread Starter

    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 (Text):
    2. private String[] rbarray;
    3. private Random random;
    4. ...
    5. ...
    6. ...
    7. rbarray =res.getStringArray(R.array.Questions);
    8. randint = random.nextInt(2);//so far I only have two items in the strin-array
    9. String question = rbarray[randint];
    10. 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?

  2. __Jon__

    __Jon__ Newbie
    Thread Starter

    Ummm... I seem to have solved it alone (with the help of this thread:
    1. http://stackoverflow.com/questions/2717614/show-random-string

    I forgot to getResources:(. Stupid mistake.

Share This Page