1. Download our Official Android App: Forums for Android!

Apps Help with string-arrays

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

  1. __Jon__

    __Jon__ Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    Aug 16, 2010

    Aug 16, 2010
    15
    0
    15
    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__ Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    Aug 16, 2010

    Aug 16, 2010
    15
    0
    15
    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...