Android can't show processdialog
mycontext.startActivity(new Intent(mycontext, logoSplash.class)); //this finishes after 3 seconds:
initcontrols();
final Timer timerStartAll = new Timer();
timerStartAll.schedule(new TimerTask() {
@Override public void run() {
handler.post(new Runnable() { public void run() {
timerStartAll.cancel();
start();
}});
}
}, 4000, 5000);
function starts:
utils.showLoaderDia开发者_开发技巧log("refresh!", "refresh.");
in utils class:
public static ProgressDialog dialog;
public static void showLoaderDialog(String sHead, String sMess) {
dialog =ProgressDialog.show(myActivityStart.mycontext, sHead, sMess, true, true);
}
public static void hideLoaderDialog() {
dialog.dismiss();
}
Why can't I see the process dialog?
Write this in onCreate method
ProgressDialog pd = ProgressDialog.show(this, "", "Please Wait...", true, false);
Thread th = new Thread(videoList);
th.start();
And then add this functions
public Runnable videoList = new Runnable() {
public void run() {
//your code
handler.sendEmptyMessage(0);
}
};
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (pd != null)
pd.dismiss();
}
};
精彩评论