Romulus 的筆記
RSS · 日本語 · 寫文章
Romulus 的文章歸檔

[Android] ListActivity API的一格洞

Sep 18, 2008
Android

我們先來看看API的敘述

... To do this, your own view MUST contain a ListView object with the id "@android:id/list" ...

所以我的main.xml有著這個
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight = "1"
/>

然後我就吃了這個:
09-18 07:35:08.446: ERROR/AndroidRuntime(518): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.iii.ro.iiimpa/org.iii.ro.iiimpa.iiimpa}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

總之這是API改版時沒改文件,現在所有xml上的"id"屬性都要變成android:id,然後後面的東西都一樣,所以是
android:id="android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight = "1"
/>

只能說group萬歲,大家互相幫助超棒 -_-