I am using the following code to show dynamic progress dialog :
public void loading()
{
final int WelcomeScreenDisplay=1000;
progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(true);
progressDialog.setMessage("Loading...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.incrementProgressBy(10);
progressDialog.show();
Thread WelcomeThread=new Thread()
{
int wait=0;
public void run()
{
try
{
super.run();
while(wait<WelcomeScreenDisplay)
{
sleep(100);
// progressDialog.setProgress(0);
progressDialog.incrementProgressBy(10);
wait+=100;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
WelcomeThread.start();
}
but there is some problem as:
1) when calling this function on button click,then loading bar is displayed after 10-15 seconds and
2) When user enter username and password and click on login button, then progress bar is being displayed and using intent when activity jump from Login page to another,then while loading the dynamic contents of 2nd page,a blank screen is display in between both the pages for 1-2 mins
I wanted to know that what changes I will implement so that this blank screen should not come…and my application jumps from 1 page to another when the loading completes.
Use AsyncTask whenever you are performing such operations . Here is a sample
Now in your program to call this task you need to do this
Make sure you do not have any operation in the main UI thread after this statement