I have learn how to get progressbar works with perticular task from here.
But i am using chronometer in my app. And based on that value i want to set the ProgressBar.
So how to do it. ?
I have made this thread to work.
Code:
// Start lengthy operation in a background thread
progressThread = new Thread(new Runnable() {
public void run() {
while (mProgressStatus < 100) {
mProgressStatus = doWork();
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
progressBar.setProgress(mProgressStatus);
}
});
}
}
});
progressThread.start();
I know that i have to make task that continous return the int data to the progressStatus. But how to do it with chronometer that i dont know. So please help me for that.
Thanks.
Your problem seem to be your doWork() method (as you mentioned in comment that there is nothing done in that method). As you can see progress of the progressBar depends from this method:
Lets suppose that your cronometer is updating every second, so the progressBar will be full when 100 seconds will pass. To achive that, your doWork method should return increasing value of seconds passed, i.e 1,2,3…to 100. But returning that value only is not enough, because with your current code the progressBar will be filled instantly.
The most simple solution would be:
Hope this helps,
Serhiy.