Android Progressbar not updating

前端 未结 5 1390
情深已故
情深已故 2021-01-28 22:33

i got a problem in updating progress bar. I am updating progress bar in separate Thread and the variable on which the progressbar progress is depending(which is a class variable

5条回答
  •  我在风中等你
    2021-01-28 23:16

    There are something wrong with your logic. Change your thread to following

    Thread thread = new Thread()
    {
        public void run()
        {
            int prog = 0;
             while(prog < 100)
             {
    
                 progressBar.setProgress(prog);
                 try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                 prog ++;
             }
        }
    };
    thread.start();
    

提交回复
热议问题