2008年9月18日 星期四

[Android] ListActivity API的一格洞

我們先來看看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萬歲,大家互相幫助超棒 -_-

沒有留言:

張貼留言