Help with string-arrays


Last Updated:

  1. __Jon__

    __Jon__ Member This Topic's Starter

    Joined:
    Aug 16, 2010
    Messages:
    15
    Likes Received:
    0
    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):
    1.  
    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);
    11.  
    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?
     

    Advertisement
  2. __Jon__

    __Jon__ Member This Topic's Starter

    Joined:
    Aug 16, 2010
    Messages:
    15
    Likes Received:
    0
    Ummm... I seem to have solved it alone (with the help of this thread:
    HTML:
    1. http://stackoverflow.com/questions/2717614/show-random-string
    )

    I forgot to getResources:(. Stupid mistake.
     

Share This Page

Loading...