0
votes

i m updating the progress of a progressbar in a side thread and displaying the progressbar by posting a runnable using handler the is defined in the MainActivity class(UI Thread) but still i am getting the error....!!! please help????
the following code is inside the "public void run()" method of a class that has implemented the Runnable interface.

          for (int i = 0; i < 11; ++i) {
            try {
                Thread.sleep(500);

            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            final int x = i;
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pb.setProgress(x * 10);
                }
            };
            handler.post(r2);

        }
1
the following code is inside "public void run()" method of a class that has implemented Runnable interface...!!!utkarshMahehswari

1 Answers

0
votes
  • use AsyncTask for the purpose instead of posting runnables.

  • use sending messages.

  • make sure the progress bar in set correctly in the xml file.