Explanation of code on page 40


The following code works, but I’m not sure why. Why does the Text View take an int and display the string successfully?
What is going on here?

// Get a reference to the text view mQuestionTextView = (TextView)findViewById(R.id.question_text_view); int question = mQuestionBank[mCurrentIndex].getQuestion(); mQuestionTextView.setText(question);


See p. 33, first line:
[color=#0000FF]“Why is mQuestion an int and not a String? The mQuestion variable will hold the resource ID (always an int) of a string resource for the question.”[/color]

If still not clear, look at the constructor of TrueFalse being called on Listin 2.6 on Page 39.


Could anyone please explain why we need to add .getQuestion() at the end of line
int question = mQuestionBank[mCurrentIndex].getQuestion();