Slaine82
Newbie
Hi there, I am new to Android development and I am setting up my first application which is a simple 10 question quiz. I have the questions text set up in the strings.xml
<string name="question_1">Question 1 here</string>
<string name="question_2">Question 2 here</string>
and in my java file I have a int variable which holds the current question that the user is on:-
int currentQ = 1;
I then want to set the TextView to the relevant question text but use the currentQ variable to denote which text to set. So instead of:-
TextView t = new TextView(this);
t = (TextView)findViewById(R.id.questionView);
String string = getString(R.string.question_1);
t.setText(string);
I want to set it dynamically something like
"R.string.question_" + currentQ
is it possible to do anything like this concatenate the variable to retrieve the string?
Any advice or help greatly appreciated!
<string name="question_1">Question 1 here</string>
<string name="question_2">Question 2 here</string>
and in my java file I have a int variable which holds the current question that the user is on:-
int currentQ = 1;
I then want to set the TextView to the relevant question text but use the currentQ variable to denote which text to set. So instead of:-
TextView t = new TextView(this);
t = (TextView)findViewById(R.id.questionView);
String string = getString(R.string.question_1);
t.setText(string);
I want to set it dynamically something like
"R.string.question_" + currentQ
is it possible to do anything like this concatenate the variable to retrieve the string?
Any advice or help greatly appreciated!
