代码之家  ›  专栏  ›  技术社区  ›  lacas

Android无法显示ProcessDialog

  •  0
  • lacas  · 技术社区  · 14 年前
        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 回复  |  直到 10 年前
        1
  •  1
  •   krunal shah    14 年前

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