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

沒有留言:

CODE { display: block; /* fixes a strange ie margin bug */ font-family: Courier New; font-size: 8pt; overflow:auto; background: #f0f0f0 url(http://klcintw.images.googlepages.com/Code_BG.gif) left top repeat-y; border: 1px solid #ccc; padding: 10px 10px 10px 21px; max-height:200px; height:200px; // for IE6 line-height: 1.2em; } #quote { display: block; /* fixes a strange ie margin bug */ font-family: Verdana; font-size: 10pt; overflow:auto; background: #f7f7f7 url(http://lh5.ggpht.com/_z-VThISftkI/SXUlpyfw9ZI/AAAAAAAABYY/e3GUx9_Z4TE/s288/quote-l.gif) left top no-repeat; border: 4px dotted #ccc; padding: 15px 15px 15px 31px; /*up right bottom left*/ max-height:300px; line-height: 1.2em; }