final String query = "SELECT " +
"questiontable.QuestionID, questiontable.answer0, questiontable.answer1, questiontable.answer2, questiontable.answer3, questiontable.answer4, questiontable.Correct, " +
" FROM questiontable" +
" WHERE questiontable.QuestionID IN ( " +
allQuestionIds +
" ) ORDER BY questiontable.QuestionID ";
this.cursor = this.db.rawQuery(query, null);
if (this.cursor.moveToFirst()) {
do {
for (final Question q : questions) {
if (q.getQuestionId() == this.cursor.getInt(0)) {
q.addAnswer(new Answer(this.cursor.getString(1),
this.cursor.getString(2),
this.cursor.getString(3),
this.cursor.getString(4),
this.cursor.getString(5),
(this.cursor.getInt(6) == 1 ? true : false)));
}
}
} while (this.cursor.moveToNext());
}
this.cursor.close();
我想添加this.sample()像:
q.addAnswer(new Answer(this.sample(),
this.cursor.getString(1),
this.cursor.getString(2),
this.cursor.getString(3),
this.cursor.getString(4),
this.cursor.getString(5),
(this.cursor.getInt(6) == 1 ? true : false)));
我想做的事:
*创建一个 sample() 方法,它将获取我的整数值 (AnswerID)
*AnswerID 将是一个整数值,取 QuestionID (this.cursor.getInt(0)) 的整数值并接近它;一个从 0 到 4 的数字。因此,对于每个 QuestionID,我将有 5 个值(10,11,12,13,14 - 20,21,22,23,24 - ......)
*使用 this.sample()
我的代码是我想象的(可能完全错误)
void sample (int AnswerID) {
for (int i = 0; i < 5; i++) {
AnswerID = this.cursor.getInt(0) + i ;
}
this.sample = sample;
}