显示进度对话框时按主页按钮会抛出异常

时间:2011-03-18 07:30:07

标签: android exception listview adapter progressdialog

我发送了一个服务器请求,并向用户显示了一个包含以下属性的进度对话框

waitDialog = new ProgressDialog(this);
        waitDialog.setMessage(getText(R.string.msg_plz_wait));
        waitDialog.setIndeterminate(true);
        waitDialog.show(); 

步骤1:已发送服务器请求

步骤2:显示用户对话

步骤3:当对话框可见并显示

时,用户按下主页按钮

步骤4:数据来自服务器传递给列表适配器但找不到资源并抛出Resource not found异常处理,然后ProgressDialog抛出异常。

03-18 12:18:11.050: ERROR/AndroidRuntime(15113): FATAL EXCEPTION: main
03-18 12:18:11.050: ERROR/AndroidRuntime(15113): java.lang.NullPointerException
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.AbsListView.obtainView(AbsListView.java:1432)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.ListView.makeAndAddView(ListView.java:1745)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.ListView.fillDown(ListView.java:670)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.ListView.fillFromTop(ListView.java:727)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.ListView.layoutChildren(ListView.java:1598)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.AbsListView.onLayout(AbsListView.java:1260)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.View.layout(View.java:7175)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.os.Looper.loop(Looper.java:123)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at android.app.ActivityThread.main(ActivityThread.java:3683)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at java.lang.reflect.Method.invokeNative(Native Method)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at java.lang.reflect.Method.invoke(Method.java:507)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-18 12:18:11.050: ERROR/AndroidRuntime(15113):     at dalvik.system.NativeStart.main(Native Method)

3 个答案:

答案 0 :(得分:0)

恕我直言,它与ProgressDialog无关,但是由于列表视图引起的,这是我根据你的问题所能告诉的。

答案 1 :(得分:0)

这不是你进步的对话。

在您的服务器请求准备好之后,这是您正在做的事情。

如果用户没有按主页按钮,会发生什么?问题是否仍然存在?

答案 2 :(得分:0)

您是否尝试过waitDialog.setCancelable(false)?这有什么不同吗?