我从一本书构建了我的第一个Android程序。它不断崩溃在一个XML文件上。我从书中下载了xml代码,使用它,它运行良好!为什么我的XML代码在与其他运行正常的XML代码相同时崩溃?
当我看着它们时,它们都与我一样!我是否缺少关于XML的东西 - 有没有有趣的空白空间问题,首都,特殊字符还是让我的XML只有一个奇怪的gremlin!
它现在正在工作,但我想知道为什么。
This Works!
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip">
<TextView
android:id="@+id/about_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text" />
</ScrollView>
这不起作用:崩溃:java.lang.runtime.exception。二进制xml文件lin#1:您必须提供layout_width属性。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android.layout_width="fill_parent"
android.layout_height="fill_parent"
android:padding="10dip">
<TextView
android:id="@+id/about_content"
android.width ="wrap_content"
android.height ="wrap_content"
android:text="@string/about_text"/>
</ScrollView>
我想你应该留意缺少'layout_width'属性。另外,您可能希望向我们展示您的XML,以便我们可以帮助您。 – 2011-05-23 20:49:47
@Lukas - 缺少的xml是一个SO格式问题。 – 2011-05-23 20:51:03
android.width是错误的。它应该是android:width。这也适用于其他属性 – Jodes 2011-05-23 20:55:51