作者odin2008 (奧丁2008)
看板AndroidDev
標題[問題] 自定義的 widget
時間Tue Aug 21 17:09:02 2012
自定義了一個 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
1F:→ bukiya:我猜有可能是id的問題,改個普通的id試看看 08/21 19:13
3F:→ asilzheng:Descendants of these classes are not supported. 08/21 21:40
4F:→ asilzheng:不過 錯誤訊息是說轉型失敗.... 08/21 21:44