Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用SQLite数据库中的数据更新TextView?_Android - Fatal编程技术网

Android 如何使用SQLite数据库中的数据更新TextView?

Android 如何使用SQLite数据库中的数据更新TextView?,android,Android,这是每当单击按钮时,我需要在TextView中更新的代码。select接受一个随机整数并构造查询 public void trueButtonClicked(View view){ if(correct==1){ select = Math.abs(random.nextInt(8)); stringSelect = Integer.toString(select); curs

这是每当单击按钮时,我需要在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);
            }
        }

inti=4看起来不太可能是的。那是为了测试目的。立即更新您的查询可能只返回1个结果<代码>移动位置(i)
没有意义。使用
moveToFirst
我应该先将光标移动到第一个位置,然后再移动到随机位置吗?您不必移动到随机位置,因为您的查询根据随机
\u id
显式选择一行。(有更好的方法可以做到这一点,但那将是另一个问题)