在.xml文件中除以零错误

在我创build的android应用程序中,在\ res \ layout \ admin.xml中创buildxml文件

我使用的布局是:

<ScrollView > <LinearLayout > <TableLayout> . . Components . . </TableLayout> <TableLayout> . . Components . . </TableLayout> </LinearLayout> </ScrollView> 

错误

 !ENTRY com.android.ide.eclipse.adt 4 0 2011-11-17 13:35:10.046 !MESSAGE admin_view_pin.xml: / by zero !STACK 0 java.lang.ArithmeticException: / by zero at android.widget.TableLayout.mutateColumnsWidth(TableLayout.java:579) at android.widget.TableLayout.shrinkAndStretchColumns(TableLayout.java:568) at android.widget.TableLayout.measureVertical(TableLayout.java:466) at android.widget.TableLayout.onMeasure(TableLayout.java:431) at android.view.View.measure(View.java:10577) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4270) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284) at android.widget.LinearLayout.measureVertical(LinearLayout.java:613) at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) at android.view.View.measure(View.java:10577) at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1090) at android.widget.FrameLayout.onMeasure(FrameLayout.java:267) at android.widget.ScrollView.onMeasure(ScrollView.java:314) at android.view.View.measure(View.java:10577) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4270) at android.widget.FrameLayout.onMeasure(FrameLayout.java:267) at android.view.View.measure(View.java:10577) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4270) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284) at android.widget.LinearLayout.measureVertical(LinearLayout.java:613) at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) at android.view.View.measure(View.java:10577) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4270) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284) at android.widget.LinearLayout.measureVertical(LinearLayout.java:613) at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) at android.view.View.measure(View.java:10577) at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:397) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:316) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:380) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1310) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1075) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:901) at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(LayoutEditor.java:403) at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575) at org.eclipse.equinox.launcher.Main.run(Main.java:1408) 

请指导我如何删除这个错误,也想知道为什么这个错误发生?

admin_view_pin.xml

 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" style="@style/white_background_bl_aatharv"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_parent"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:scrollbars="vertical" android:scrollbarAlwaysDrawVerticalTrack="true"> <Button android:id="@+id/btnLogout" android:layout_gravity="right" android:text="Logout" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/button_bl" /> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars="vertical" android:scrollbarAlwaysDrawVerticalTrack="true" android:stretchColumns="*"> <TableRow> <TextView android:text="Select" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <RadioGroup android:layout_width="fill_parent" android:id="@+id/selectRadioGroup" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:id="@+id/radio_datewise" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Date Wise" /> <RadioButton android:id="@+id/radio_IDwise" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ID Wise" /> </RadioGroup> </LinearLayout> </TableRow> <TableRow> <TextView android:text="MemberID" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <EditText android:id="@+id/txtMemberID" android:layout_width="120dip" android:singleLine="true" android:layout_height="wrap_content" android:enabled="false" /> </TableRow> <TableRow> <TextView android:text="From Date" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <EditText android:id="@+id/startDate" android:layout_width="120dip" android:singleLine="true" android:layout_height="wrap_content" android:editable="false" android:enabled="false" /> <Button android:layout_height="wrap_content" style="@style/button_bl" android:layout_width="wrap_content" android:gravity="center" android:id="@+id/btnStartDate" android:text="Set Date" android:layout_gravity="center" android:enabled="false" /> </LinearLayout> </TableRow> <TableRow> <TextView android:layout_width="wrap_content" android:text="To Date" android:layout_height="fill_parent" android:gravity="center" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <EditText android:id="@+id/endDate" android:layout_width="120dip" android:singleLine="true" android:layout_height="wrap_content" android:editable="false" android:enabled="false" /> <Button android:id="@+id/btnEndDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Set Date" android:gravity="center" style="@style/button_bl" android:layout_gravity="center" android:enabled="false" /> </LinearLayout> </TableRow> <TableRow> <TextView android:text="Package Type" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <Spinner android:id="@+id/spnPackageType" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <TableRow> <TextView android:text="Status" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <Spinner android:id="@+id/spnStatus" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <TableRow> <TextView android:text="Active Status" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="center" /> <Spinner android:id="@+id/spnActStatus" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <TableRow android:layout_gravity="center" android:gravity="center"> <Button android:id="@+id/btnGetDetails" android:layout_width="wrap_content" android:gravity="center" android:text="Get Details" android:layout_height="wrap_content" style="@style/button_bl" /> </TableRow> </TableLayout> <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" android:scrollbars="vertical" android:scrollbarAlwaysDrawVerticalTrack="true" android:id="@+id/pinDetailsTable"> <TableRow> <!-- <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> --> </TableRow> </TableLayout> </LinearLayout> </HorizontalScrollView> </ScrollView> 

当我从布局中删除HorizontalScrollView我得到这个错误

Solutions Collecting From Web of "在.xml文件中除以零错误"

我认为你的第二个表格布局,它没有任何列,但你正试图把它们全部拉伸。

 <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" android:scrollbars="vertical" android:scrollbarAlwaysDrawVerticalTrack="true" android:id="@+id/pinDetailsTable"> <TableRow> <!-- <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> <TextView android:text="" android:padding="3dip" style="@style/text_subheader_wh" /> --> </TableRow> </TableLayout> 

尝试包括在整个文件的顶部。 它解决了我的问题!

(没有在骑马的外面qoutes)

 <?xml version="1.0" encoding="utf-8"?>