I have a strings.xml file that takes the following format (in general):

<string name="q0"></string>
    <string name="q0a1"></string>
    <string name="q0a2"></string>
    <string name="q0a3"></string>
    <string name="q0a4"></string>
    <string name="q0KEY">1</string>
    <string name="q0ANS">ans-a01</string>


There are 200+ questions and response sets.  I am trying to select a random
one, (say q183) and then use the text in a text view like such:

        Random rGenerator = new Random();
        int randomQ = rGenerator.nextInt(204);
        String Q_ID = 'q' + getString(randomQ);
        List<Integer> intlist = new ArrayList<Integer>();
        intlist.add(new Integer(1));
        intlist.add(new Integer(2));
        intlist.add(new Integer(3));
        intlist.add(new Integer(4));
        Collections.shuffle(intlist);
        String ANS_ID1 = "R.string."+Q_ID + "a"+getString(intlist.get(0));
        String ANS_ID2 = "R.string."+Q_ID + "a"+getString(intlist.get(1));
        String ANS_ID3 = "R.string."+Q_ID + "a"+getString(intlist.get(2));
        String ANS_ID4 = "R.string."+Q_ID + "a"+getString(intlist.get(3));
        String Question = getString(R.string.Q_ID); //this is considedered a
syntax error by java/android
        TextView QuestionView = (TextView) findViewById(R.id.QuestionText);
        QuestionView.setText(Question);

No matter how I construct (at least, as I can think of it) the text of the
string to pass as a parameter to the value of Question, I end up with
problems.

At this point I absolutely need to be able to choose an arbitrary string
from strings.xml, with the specific set of strings to follow.

Any help would be appreciated.  Yes I know a database *might* be simpler,
but I cannot figure out the proper code to make this work either.  The ONE
tutorial on the subject leaves out critical information.  I really need help
on this.

Thanks

Ben

-- 
I have no bit of wisdom to include as a signature.

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to