Android 错误:无法';t从游标窗口读取第0行第1列在从游标窗口访问数据之前,确保游标已正确初始化?
这个代码有什么问题?我不知道(游标中)出现了什么错误。问题是游标不包含任何结果。可能是由错误的查询引起的 问题是光标不包含任何结果。可能是由错误的查询引起的 您的查询字符串可能有问题。请确保您的表Android 错误:无法';t从游标窗口读取第0行第1列在从游标窗口访问数据之前,确保游标已正确初始化?,android,Android,这个代码有什么问题?我不知道(游标中)出现了什么错误。问题是游标不包含任何结果。可能是由错误的查询引起的 问题是光标不包含任何结果。可能是由错误的查询引起的 您的查询字符串可能有问题。请确保您的表问题和列主题id拼写正确…..如果您在初始化数据库和表时看到代码(请包括SQL字符串),将非常有帮助…..您的查询字符串可能有问题。请确保您的表问题和列主题id拼写正确…..如果您在初始化数据库和表时看到您的代码(请包括SQL字符串),将非常有帮助。。。。 private void populateQu
问题
和列主题id
拼写正确…..如果您在初始化数据库和表时看到代码(请包括SQL字符串),将非常有帮助…..您的查询字符串可能有问题。请确保您的表问题
和列主题id
拼写正确…..如果您在初始化数据库和表时看到您的代码(请包括SQL字符串),将非常有帮助。。。。
private void populateQuestionList() {
int QuestionTableSubjectId = questionModelObject.getSubjectId();
ArrayList<QuestionModel> questionArrayList = QuestionManager.getQuestionManager(this).getQuestionBySubjectID(QuestionTableSubjectId);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (int i = 0; i < questionArrayList.size(); i++) {
TableRow row = (TableRow) inflater.inflate(R.layout.item_ctrl_list_row, null);
row.setOnClickListener(this);
TextView questionTV = (TextView) row.findViewById(R.id.tv_ctrl_name);
String question = questionArrayList.get(i).getQuestion();
questionTV.setText(question);
row.setTag(questionArrayList.get(i));
questionList.addView(row);
}
}
public ArrayList<QuestionModel> getQuestionBySubjectID(int subjectId) {
ArrayList<QuestionModel> questionArrayList = new ArrayList();
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("select * from Questions where subject_id=" + subjectId, null);
res.moveToFirst();
while (res.isAfterLast() == false) {
QuestionModel questionModelObject = new QuestionModel();
questionModelObject.setQuestionId(res.getInt(res.getColumnIndex("questionId")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("question")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerOne")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerTwo")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerThree")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerFour")));
questionModelObject.setAnswerOne(res.getString(res.getColumnIndex("correctAnswer")));
questionArrayList.add(questionModelObject);
res.moveToNext();
}
return questionArrayList;
}