Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 减慢进度条进度_Android_Multithreading_While Loop_Android Canvas - Fatal编程技术网

Android 减慢进度条进度

Android 减慢进度条进度,android,multithreading,while-loop,android-canvas,Android,Multithreading,While Loop,Android Canvas,我在这里使用这段代码在自定义progressbar上循环和更新进度 class MyThreadRunner implements Runnable { // @Override int count = 0; public void run() { try { while (count < 90) { Thread.sleep(10);

我在这里使用这段代码在自定义progressbar上循环和更新进度

class MyThreadRunner implements Runnable {
        // @Override
     int count = 0;
        public void run() {
            try {
            while (count < 90) {
                Thread.sleep(10);
                count += 1;
                 progressBar.setProgress(count);
                 progressBar.setText(count + "%");
            }
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                }
 };
类MyThreadRunner实现可运行{
//@覆盖
整数计数=0;
公开募捐{
试一试{
同时(计数<90){
睡眠(10);
计数+=1;
progressBar.setProgress(计数);
progressBar.setText(计数+“%”);
}
}捕捉(中断异常e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
};

当它接近尾声时,我希望它开始减速,这是否可能,而不必进行另一个while循环?

为什么不改变睡眠时间,使其值超过90

    class MyThreadRunner implements Runnable {
        // @Override
     int count = 0;
        public void run() {
            try {

            while (count < 100) {

                //500 is half a second...
                int sleepTime = count < 90 ? 10 : 500;
                Thread.sleep(sleepTime);

                count += 1;
                 progressBar.setProgress(count);
                 progressBar.setText(count + "%");
            }
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                }
 };     
类MyThreadRunner实现可运行{
//@覆盖
整数计数=0;
公开募捐{
试一试{
同时(计数<100){
//500是半秒。。。
int sleepTime=计数<90?10:500;
睡眠(睡眠时间);
计数+=1;
progressBar.setProgress(计数);
progressBar.setText(计数+“%”);
}
}捕捉(中断异常e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
};     
类MyThreadRunner实现可运行{
//@覆盖
整数计数=0;
int sleepTime=0;
公开募捐{
同时(计数<100){
睡眠时间=计数<90?10:100;
睡眠(睡眠时间);
}
};
class MyThreadRunner implements Runnable {
        // @Override
     int count = 0;
     int sleepTime = 0;
        public void run() {

            while (count < 100) {
                sleepTime = count < 90 ? 10 : 100;
                Thread.sleep(sleeptime);

            }


 };