Der Versuch, ein Griff auf Android zu bekommen throught Der große Nerd Ranch Guide, ich auf dieses Beispiel kam:Android Textview Ressource nicht gefunden
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
mQuestionTextView = (TextView) findViewById(R.id.question_text_view);
int question = mQuestionBank[mCurrentIndex].getTextResId();
mQuestionTextView.setText(question);
wo mQuestionBank
private Question[] mQuestionBank = new Question[] {
new Question(R.string.question_oceans, true),
new Question(R.string.question_mideast, false),
new Question(R.string.question_africa, false),
new Question(R.string.question_americas, true),
new Question(R.string.question_asia, true),
};
und diejenigen definiert wurden, in strings.xml
<string name="question_oceans">The Pacific Ocean is larger than the Atlantic Ocean.</string>
<string name="question_mideast">The Suez Canal connects the Red Sea and the Indian Ocean.</string>
<string name="question_africa">The source of the Nile River is in Egypt.</string>
<string name="question_americas">The Amazon River is the longest river in the Americas.</string>
<string name="question_asia">Lake Baikal is the world\'s oldest and deepest freshwater lake.</string>
aber ich bin eine Ressource nicht gefunden Ausnahme bekommen. (textResId ist das erste Feld der Frage Klasse)
EDIT:
Frage Klasse
public class Question {
private int mTextResId;
private boolean mAnswerTrue;
public Question(int mTextResId, boolean mAnswerTrue) {
mTextResId=mTextResId;
mAnswerTrue=mAnswerTrue;
}
public int getTextResId() {
return mTextResId;
}
public void setTextResId(int textResId) {
mTextResId = textResId;
}
public boolean isAnswerTrue() {
return mAnswerTrue;
}
public void setAnswerTrue(boolean answerTrue) {
mAnswerTrue = answerTrue;
}
Was ist mCurrentIndex? –
poste deine logcat Ausgabe –
mCurrentIndex ist eine private int = 0 – Boulbi