看板 AndroidDev 關於我們 聯絡資訊
自定義了一個 ListView 的 Widget 錯誤是發生在 setContentView 時 而我的 layout 如下 -------------------------------------------------------------- <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <demo.my.widget.myListView android:id="@+id/android:list" android1:layout_width="match_parent" android1:layout_height="wrap_content" /> </LinearLayout> -------------------------------------------------------------- 可是會出現這樣的錯誤訊息 demo.my.widget.myListView failed to instantiate. 堆疊的最後一個是這個 java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.RelativeLayout 試過 Clean... 沒輒 我自己定義的 ListView Widget 是放在 demo.my.widget 下 就如同錯誤訊息裡的那個 package name 而程式是在 demo.my.activity 這個 package 裡 一直無解,懇請提供方向,感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.251.154.220
bukiya:我猜有可能是id的問題,改個普通的id試看看 08/21 19:13
asilzheng:http://tinyurl.com/ykczs6d 這個項目的最後一行 08/21 21:40
asilzheng:Descendants of these classes are not supported. 08/21 21:40
asilzheng:不過 錯誤訊息是說轉型失敗.... 08/21 21:44