Listing 2.7 cannot resolve crash


#1

The issue is listing 2.7 with this code:

int question = questionBank[currentIndex].getTextResId() ;
questionTextView.setText(question);

it crashes and I can not figure out why. Can anyone help?

here is the Question.java

public class Question {

private int textResId;
private boolean answerTrue;
public Question( int textResId, boolean answerTrue){
    this.textResId = textResId;
    this.answerTrue = answerTrue;
}
public int getTextResId() {
    return textResId;
}
public void setTextResId(int textResId) {
    this.textResId = textResId;
}
public boolean isAnswerTrue() {
    return answerTrue;
}
public void setAnswerTrue(boolean answerTrue) {
    this.answerTrue = answerTrue;
}

}

thx


#2

Resolved, don’t know why but it is working.


#3

Hi Grady,
How it works for you ?
I am new to Android and stuck at this point, whenever I run my app it crashes.
I turned this piece of code into this as well
mQuestionTextView.setText(Integer.toString(question)); but it show me 0 instead of question text.
Any solution ?