-1

I searched and found what looked like the exact question I have (http://stackoverflow.com/questions/4369537/update-ui-from-thread). Unfortunately I'm still not able to get this working.

I have an ImageView on my layout. When a button is pressed, a ProgressDialog is created and shown. As the thread processes data, it calls the incrementProgressBy() method on a handler in the UI. Inside that handler, I update the ImageView using setImageBitmap(), and then I Invalidate it. It never updates. Next, I tried calling ImageView.postInvalidate() from the progress bar's thread. It still does not update until the progress bar completes and is removed.

Any ideas?

Paul
  • 5,700
  • 5
  • 43
  • 67
  • Sounds like you're doing it correctly as far as the handler. It's not necessary to invalidate the bitmap since setImageBitmap() does that already. – BitBank Mar 08 '11 at 14:55
  • 1
    You should post your code. Also you know when you display a ProgressDialog your activity is paused. Maybe that's the reason? Can you try all the same without ProgressDialog. – Fedor Mar 08 '11 at 15:00
  • I really can't go without the dialog. Essentially, the user takes photos with the application and enters information. These photos are uploaded to a web service later. The progress bar indicates how many photos have gone and how many are left. Since the progress dialog does not cover the whole screen I thought it would be nice to display the image being sent in the background. – Paul Mar 08 '11 at 21:57

1 Answers1

0

The solution here was to use an AsyncTask. It's able to communicate with the UI via handlers.

Paul
  • 5,700
  • 5
  • 43
  • 67