我從一本書構建了我的第一個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