Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use setProgressDrawable() correctly?

I am having problem with setting a new Drawable to my ProgressBar.

If I use the setProgressDrawable() inside onCreate() method it works great. But when I try to call the same method inside a Handler post callback it doesn't work and the progressbar disapears.

Can someone explain this behaviour? How can I solve this problem?

like image 765
Martin Avatar asked Feb 17 '10 13:02

Martin


1 Answers

downloadingBar.setProgress(0); 

Drawable progressDrawable = getResources().getDrawable(R.drawable.download_progressbar_pause_bg);

progressDrawable.setBounds(downloadingBar.getProgressDrawable().getBounds()); 

downloadingBar.setProgressDrawable(progressDrawable); 

downloadingBar.setProgress(mCurrentPercent);  
  1. First you should reset the progress to zero
  2. Set the progress drawable bounds
  3. Set new progress drawable
  4. Set new progress
like image 93
perry Avatar answered Oct 21 '22 16:10

perry