Reputation:
new Thread(new Runnable()
{
public void run() {
while ( statusStr==null)
{
progressBarHandler.post(new Runnable() {
public void run() {
progressBar.setProgress(progressBarStatus);
}
});
}
}
}).start();
Friends,I have referred other question but I am still confused so please help me in solving this issue. I cannot keep statusStr as final coz its values are updating while the app is working so please give me a solution.
Upvotes: 0
Views: 2092
Reputation: 29199
Either declare progressBar as final or declare it as a GlobalVariable.
Like declaring final variable do as follows:
final ProgressBar progressBar= ProgressBar.show(this, "title", "message");
new Thread(new Runnable()
{
public void run() {
while ( statusStr==null)
{
progressBarHandler.post(new Runnable() {
public void run() {
progressBar.setProgress(progressBarStatus);
}
});
}
}
}).start();
Upvotes: 0
Reputation: 54322
You can declare the variable globally so that you will not be forced to change it to final.
Upvotes: 3