进度对话框在启动新活动 [英] Progress Dialog while starting new activity

查看:132
本文介绍了进度对话框在启动新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此按钮显示在我的开始活动。后pressing它一个新的活动将被启动,但这需要一定的时间造成的一些数据从因特网收集的新活动的初始化。 这个工程的一半。进度dialoge显示但进展车轮不转动。

this button is shown on my start activity. After pressing it a new activity will be launched but this takes some time cause on initialization of that new activity some data is gathered from the Internet. This works half. The progress dialoge is shown but the progress wheel is not spinning.

有谁能告诉我,为什么出现这种情况?

Can somebody tell me why this happens?

  Button b4 = (Button) findViewById(R.id.Button01);
      b4.setOnClickListener(new View.OnClickListener() {
          public void onClick (View view) {    
           final ProgressDialog pd = ProgressDialog.show(pak.this, 
                         "", "Working..", true);

            new Thread(new Runnable(){
             public void run(){
              Intent intent = new Intent();
                 intent.setClassName("sxe.pak", "sxe.pak.List");
                 startActivity(intent);               
              pd.dismiss();
                }
           }).start();

          }
   });

THX

推荐答案

您需要显示的进展在你的第二个活动,而不是你的第一个一开始对话框。而你需要做的数据下载工作在AsyncTask的。

You need to show the progress dialog at the very start of your 2nd Activity, not your first one. And you need to do your data download work in an AsyncTask.

请参阅我的答案,这更多的信息:

See my answer to this for more info:

<一个href="http://stackoverflow.com/questions/1979524/android-splashscreen">http://stackoverflow.com/questions/1979524/android-splashscreen

这篇关于进度对话框在启动新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆