2

我是这个网站的新手,所以请原谅我的格式问题。我的问题是,当我尝试在我的 xml 文档的图形布局选项卡中向我的 xml TableLayout 添加一行时,我在 eclipse 中遇到了这个错误。我的错误如下

Exception raised during rendering: / by zero
Exception details are logged in Window > Show View > Error Log

这是我的 XML 代码。出于某种原因,即使在 main.xml 文件中自动添加了一行,图形布局也会显示错误。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tableLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:padding="5dp"
    android:stretchColumns="*" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </TableRow>

</TableLayout>

如果您对我做错了什么有任何想法,或者您需要更多信息,请告诉我。

4

2 回答 2

6

android:stretchColumns="*"从 TableLayout 中删除。

或者请提供任何数字而不是“*”,例如android:stretchColumns="2"

于 2012-12-29T12:34:45.460 回答
3

我偶然发现了同样的问题,我想我们都在关注 Deitel 的“Android for Programmers”一书(特别是,这个问题起源于第 127 页)。我决定放弃它并寻找其他地方。这本书明确说将 android:stretchColumns 设置为“*”,几段后他们要求您将行添加到 TableLayout。他们测试过吗?

于 2013-01-22T21:39:58.163 回答