import android.app.Activity;
import android.app.ProgressDialog;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
public class ProgressDialogActivity extends Activity {
/** Called when the activity is first created. */
ProgressDialog pro;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
setContentView(R.layout.main);
pro=new ProgressDialog(this);
pro.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pro.setMax(300);
pro.setCancelable(true);
pro.setMessage("Loading data..");
pro.show();
Threadex t=new Threadex();
t.start(); //start thread
}//This is Oncreate method
class Threadex extends Thread
{
public void run()
{
for(int i=10;i<=pro.getMax();i=i+10)
{
pro.incrementProgressBy(10);
try
{
sleep(1000); //sleep for 1 seconds
}
catch(Exception e)
{
e.printStackTrace();
}
} //this is for loop ends
pro.dismiss();
} //this is end of Run
}//This is End of Threadex
} //This is End of Activity
Here Update the 10 distance continues Upto 300 distance because we have set 300 distance as max .
This is after the Dismiss the ProgressDialog
This is for ProgressDialog.STYLE_HORIZONTAL.
we can set Another Style ProgressDialog.STYLE_SPINNER but view is different