【发布时间】:2010-09-13 09:03:51
【问题描述】:
我正在使用我的一项活动中的以下代码来启动另一项活动
Intent viewIntent = new Intent(getApplicationContext (), landingPage.class);
Bundle b = new Bundle();
b.putString("ApplicationName", a_Bean.getApplicationName());
if (landingPage.getInstanceCount() < 1)
bp.landingPage_ProgressDialog = ProgressDialog.show(ViewAllApp.this, "Please wait...", "Retrieving data...", true, false);
viewIntent.putExtras(b);
viewIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(viewIntent,10);
Thread background = new Thread(new Runnable() {
public void run() {
Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog
}});
background.start();
但是在 startactivity 之后它显示一个黑屏然后显示新的活动。 可以在显示黑屏时显示进度对话框吗?
【问题讨论】:
-
这种情况下不要显示ProgressDialog,不会有黑色滑屏效果。
-
@Pentium10 当我的应用程序根据选定的“ApplicationName”变量从 Internet 下载数据时,我需要显示 progressDialog。
-
我确实删除了 progressDialog 但无济于事。我在其他测试应用程序中也看到了相同的行为。
-
在启动应用程序之间设置进度是个坏主意。您需要在执行下载的对话框中实现进度对话框,但在切换活动之间。此外,如果您有一个简单的数据下载界面,您应该考虑使用 Service 而不是 Activity。