Android无法显示processdialog

时间:2010-10-28 08:39:06

标签: android dialog

    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);

功能开始:

utils.showLoaderDialog(“刷新!”,“刷新。”);

在utils类中:

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();
}

为什么我看不到进程对话框?

1 个答案:

答案 0 :(得分:1)

在onCreate方法中写这个

    ProgressDialog pd = ProgressDialog.show(this, "", "Please Wait...", true, false);
    Thread th = new Thread(videoList);
    th.start();

然后添加此功能

    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();
      }
    };