这是我在单击按钮时需要在TextView中更新的代码。 select采用随机整数并构造查询。
public void trueButtonClicked(View view){
if(correct==1){
select = Math.abs(random.nextInt(8));
stringSelect = Integer.toString(select);
cursor = db.query("QUESTION_TABLE",new String[]{"QUESTION", "isCORRECT", "DIFFICULTY"}, "_id = ?", new String[]{stringSelect},null, null, null);
if(cursor.moveToPosition(select)){
showQuestion.setText(cursor.getString(0));
correct = cursor.getInt(1);
diff = cursor.getInt(2);
}
}
else {
Intent intent = new Intent(GameScreenActivity.this, GameEndActivity.class);
startActivity(intent);
}
}