How come getQuestion() returns question text and not ID int


#1

In Chapter 2, Android and Model-View-Controller the TrueFalse.java is defined:

public class TrueFalse {
private int mQuestion;
private boolean mTrueQuestion;

public TrueFalse(int question, boolean trueQuestion) {
    mQuestion = question;
    mTrueQuestion = trueQuestion;
}

public int getQuestion() {
return mQuestion;
}

public void setQuestion(int question) {
mQuestion = question;
}

public boolean isTrueQuestion() {
return mTrueQuestion;
}

public void setTrueQuestion(boolean trueQuestion) {
mTrueQuestion = trueQuestion;
}

}

As you can see from mQuestion is of int type, but when getQuestion() is used to set the text later on, using .setText() method of TextView class, the actual question text is set.

How ?


#2

[quote=“areyoualearner”]

As you can see from mQuestion is of int type, but when getQuestion() is used to set the text later on, using .setText() method of TextView class, the actual question text is set.

How ?[/quote]

Someone correct me if I am wrong.

TextView’s setText() method is overloaded.
developer.android.com/reference/ … pubmethods

in this code, we are using the setText(int resid) method.