progress dialog in main activity's onCreate not shown
Posted
by
Mando
on Stack Overflow
See other posts from Stack Overflow
or by Mando
Published on 2012-06-05T22:25:15Z
Indexed on
2012/06/05
22:40 UTC
Read the original article
Hit count: 132
After the splash screen, it takes about 6 sec to load onCreate contents in the Main activity. So I want to show a progress dialog while loading and here's what I did:
import ...
private ProgressDialog mainProgress;
public void onCreate(Bundle davedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mProgress = new ProgressDialog (Main.this);
mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgress.setMessage("Loading... please wait");
mProgress.setIndeterminate(false);
mProgress.setMax(100);
mProgress.setProgress(0);
mProgress.show();
---some code---
mProgress.setProgress(50);
---some code---
mProgress.setProgress(100);
mProgress.dismiss();
}
and it doesn't work... the screen stays black for 5-6 sec and then load the main layout. I dont know which part I did wrong :*(
© Stack Overflow or respective owner