Neilz wrote:
> I'm sure there's a simple answer to this, but...
> 
> Why can't I nest another view type within a View element? In my layout
> file I try:
> 
> <View android:layout_width="wrap_content"
>         android:layout_height="wrap_content">
> 
>         <Button android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="A"/>
> </View>
> 
> ...and this gives me a ClassCastException. Why?

Because View is not a ViewGroup, and only ViewGroup (and its subclasses)
can have children. You need to use LinearLayout, FrameLayout,
RelativeLayout, etc. where you are trying to use View.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 14-18 June 2010: http://bignerdranch.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to