PROGRESS
BAR FOR WAITING IN ANDROID
public void progress(View v)
{
progressBar = new ProgressDialog(this);
progressBar.setCancelable(true);//you can cancel it
by pressing back button
progressBar.setMessage("File
downloading ...");
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);//initially
progress is 0
progressBar.setMax(100);//sets the maximum
value 100
progressBar.show();//displays the
progress bar
Thread t1=new Thread()
{
public void run()
{
while (i <= 100)
{
try {Thread.sleep(100);}
catch
(InterruptedException e) {e.printStackTrace();}
progressBar.setProgress(i);
i++;
if(i==100)
{
progressBar.dismiss();
i=0;
}
}
}
};
t1.start();
}
No comments:
Post a Comment