How Make Progress Bar For 15 Sec Loading?
codes progressBar = (ProgressBar) findViewById(R.id.progressBar); textView = (TextView) findViewById(R.id.secdelay); // Start long running operation in a b
Solution 1:
You can set the max of the progress bar to 15secs*5 = 75 to enable updating smaller 'bites' for a smoother animation.
Then update progress by 1 each 200ms.
progressBar.setMax(75)
while (progressStatus < 75) {
progressStatus += 1;
// Update the progress bar and display the//current value in the text view
handler.post(new Runnable() {
publicvoidrun() {
progressBar.setProgress(progressStatus);
textView.setText(progressStatus+"/"+progressBar.getMax());
}
});
try {
// Sleep for 200 milliseconds.//Just to display the progress slowly
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Could also sleep only 100ms using a max of 150.
Post a Comment for "How Make Progress Bar For 15 Sec Loading?"