Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.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
在3秒间隔内从android中的SQLlite数据库逐个获取数据_Android_Database_Sqlite_Handler - Fatal编程技术网

在3秒间隔内从android中的SQLlite数据库逐个获取数据

在3秒间隔内从android中的SQLlite数据库逐个获取数据,android,database,sqlite,handler,Android,Database,Sqlite,Handler,我正在创建一个应用程序,需要在其中显示我已存储在SQLLite数据库中的一些引用。 我知道如何从数据库中获取数据并将其显示在文本视图中 我需要在3秒内一个接一个地获取数据,并将其显示在文本视图中 这意味着每3秒钟,应用程序就会显示数据库中的报价 这是我的代码。 但它不起作用 //code to display quotes in a particular interval handler = new Handler(); Runnable runable = new Runnable() {

我正在创建一个应用程序,需要在其中显示我已存储在SQLLite数据库中的一些引用。
我知道如何从数据库中获取数据并将其显示在
文本视图中

我需要在3秒内一个接一个地获取数据,并将其显示在
文本视图中

这意味着每3秒钟,应用程序就会显示数据库中的报价

这是我的代码。
但它不起作用

//code to display quotes in a particular interval
handler = new Handler(); 
Runnable runable = new Runnable() 
{
    int currV = 0;
    boolean go = true;
    @Override 
    public void run() 
    {
        try
        {
            if(currV == 21 && go)
                go = false;
            else if(currV == 0 && !go)
                go = true;

            if(go)
            {
                waterquote.setText(quotelist.get(currV).getQuote());
                currV++;
            }
            else
            {
                currV--;
                waterquote.setText(quotelist.get(currV).getQuote());
            }
            //also call the same runnable 
            handler.postDelayed(this, 3000);
        }
        catch (Exception e) 
        {
            // TODO: handle exception
        }
        finally
        {
            //also call the same runnable 
            handler.postDelayed(this, 3000); 
        }
    }
}; 
handler.postDelayed(runable, 3000);

嗨,你能解释一下你的代码中有什么不起作用吗?我只能看到我插入到应用程序数据库中的最终数据。显示的数据没有变化。根据我的想法和代码,一旦到达数据库的末尾,我需要循环浏览所有数据?我可能需要增加间隔吗?因此,你想一次浏览一条记录,每隔3秒?听起来您想在moveToNext()指令后添加3秒延迟。我需要获取一个数据并在TextView中显示。然后等待一段时间间隔。如果合适,可以说是3秒。然后在该时间间隔后获取另一个数据,依此类推……您能帮我吗?您可以设置a并将其间隔设置为3000(3秒)其持续时间为1000*记录计数。然后在其
onTick()
方法中,执行光标的
moveToNext()
方法。