I'm a "fresh" Android developer and i tried the horizontal ProgressBar. I have a little issue with it, progress stops in the middle and does not continue till the end of the bar.
Can you help me please?
this is my code
progress=0;
mProgress = (ProgressBar) findViewById(R.id.progressBar1);
mProgress.setMax(200);
// Start lengthy operation in a background thread
new Thread(new Runnable()
{
public void run()
{
while (mProgressStatus < 100)
{
mProgressStatus = doWork();
// Update the progress bar
mHandler.post(new Runnable()
{
public void run()
{
mProgress.incrementProgressBy(20);
mProgress.setProgress(mProgressStatus);
}
});
}
// Cache la progressBar
mHandler.post(new Runnable()
{
@Override
public void run()
{
mProgress.setVisibility(4);
}
});
}
//---------------------------------Work to do-----------------------
private int doWork()
{
try{
Thread.sleep(50);//5 secondes
}catch(InterruptedException e)
{
e.printStackTrace();
}
return ++progress;
}
//------------------------------------------------------------------
}).start();
}