我想通過下面的代碼來清除表:java.lang.ArithmeticException:在結算表被零除
int count = table_layout_acc_statement.getChildCount();
for (int i = 0; i < count; i++) {
View child = table_layout_acc_statement.getChildAt(i);
if (child instanceof TableRow) ((ViewGroup) child).removeAllViews();
但我得到以下異常:
05-09 15:53:07.526: E/AndroidRuntime(14072): FATAL EXCEPTION: main
05-09 15:53:07.526: E/AndroidRuntime(14072): Process: com.era.customeragentapp, PID: 14072
05-09 15:53:07.526: E/AndroidRuntime(14072): java.lang.ArithmeticException: divide by zero
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.TableLayout.mutateColumnsWidth(TableLayout.java:587)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.TableLayout.shrinkAndStretchColumns(TableLayout.java:576)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.TableLayout.measureVertical(TableLayout.java:474)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.TableLayout.onMeasure(TableLayout.java:439)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.HorizontalScrollView.onMeasure(HorizontalScrollView.java:329)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
05-09 15:53:07.526: E/AndroidRuntime(14072): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
05-09 15:53:07.526: E/AndroidRuntime(14072): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2368)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.View.measure(View.java:16848)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2246)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1312)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1509)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1189)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6223)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.Choreographer.doFrame(Choreographer.java:560)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.os.Handler.handleCallback(Handler.java:808)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.os.Handler.dispatchMessage(Handler.java:103)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.os.Looper.loop(Looper.java:193)
05-09 15:53:07.526: E/AndroidRuntime(14072): at android.app.ActivityThread.main(ActivityThread.java:5330)
05-09 15:53:07.526: E/AndroidRuntime(14072): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 15:53:07.526: E/AndroidRuntime(14072): at java.lang.reflect.Method.invoke(Method.java:515)
05-09 15:53:07.526: E/AndroidRuntime(14072): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
05-09 15:53:07.526: E/AndroidRuntime(14072): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
05-09 15:53:07.526: E/AndroidRuntime(14072): at dalvik.system.NativeStart.main(Native Method)
05-09 15:53:09.402: E/(14376): appName=com.era.customeragentapp, acAppName=/system/bin/surfaceflinger
05-09 15:53:09.402: E/(14376): 0
05-09 15:53:09.402: E/(14376): appName=com.era.customeragentapp, acAppName=/system/bin/surfaceflinger
05-09 15:53:09.402: E/(14376): 0
我爲什麼得到這個錯誤?我怎樣才能解決這個錯誤?
這些異常bcoz的算術運算..... – sushildlh
嘗試添加異常。並找出它發生的地方。然後輕鬆找出問題 –
我無法找到錯誤所在的位置。 –