I have a class that extends FrameLayout called NoteView. It is a top level public class.
It works just fine when I'm creating the UI from java code, but I can't figure out how to use it in XML. I tried inserting the fully qualified class name just like I would for a custom view, but I get and exception ClassCastException: android.view.View cannot be cast to android.view.ViewGroup
when activity tries to inflate the XML.
I have only been able to find tutorials on Custom Views, not custom viewgroups. What do I need to do to use a NoteView just like I would a FrameLayout in an XML Layout?
For example: This works
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<test.cjb.sandbox.NoteView
android:id="@+id/noteview"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#FF0000"
android:layout_gravity="right">
</test.cjb.sandbox.NoteView>
<Button
android:id="@+id/button"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:text="Sibling Button"/>
</LinearLayout>
But this throws the above exception:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<test.cjb.sandbox.NoteView
android:id="@+id/noteview"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#FF0000"
android:layout_gravity="right">
<Button
android:id="@+id/button"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:text="Child Button"/>
</test.cjb.sandbox.NoteView>
</LinearLayout>