如何在android中每5秒更新进度对话框文本?

时间:2014-12-11 22:38:34

标签: android asynchronous timer callback progressdialog

我希望每隔5秒动态更改进度对话框文本....同时将数据表从MySQL同步到sqlite ...我尝试使用自定义类但仍然不会每5秒更改一次文本。 提前谢谢。

1 个答案:

答案 0 :(得分:2)

您可以尝试使用postDelayed处理程序:

Handler handler = new Handler();

public void checkProgress() {

    handler.postDelayed(new Runnable(){
               @Override
               public void run() {
                    boolean done = false;
                    mytextView.setText("updated Text");

                    // Some logic here to check when progress is done, then flip boolean

                    if (!done) {
                        checkProgress();
                    }
               }
        }, 5000);
}

我没有测试任何此代码,但这可能会让你走上正轨。