Search code examples
androidxmlandroid-relativelayoutandroid-tablelayout

How can I add an extended TableLayout to make sure it is at the bottom


I am having some issues with a custom layout (ToDoView is extending TableLayout), and I do not know how to make sure it is under everything else (by everything else, I mean the EditText, and the Buttons).

As of right now, my app crashes with:

12-18 07:11:13.886: E/AndroidRuntime(3228): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.parrishb.todo/com.parrishb.todo.ToDoActivity}: android.view.InflateException: Binary XML file line #44: Error inflating class com.parrishb.todo.ToDoView

Here is the xml file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ToDoActivity" >

    <EditText
        android:id="@+id/myEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/addItemContentDescription"
        android:hint="@string/addItemHint" />

    <Button
        android:id="@+id/pickDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/myEditText"
        android:text="Change the Date" />

    <Button
        android:id="@+id/pickTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/myEditText"
        android:layout_toRightOf="@id/pickDate"
        android:text="Change the Time" />

    <DatePicker
        android:id="@+id/datePicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TimePicker
        android:id="@+id/timePicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <com.parrishb.todo.ToDoView
        android:id="@+id/tdv"
        class="com.parrishb.todo.ToDoView"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_below="@id/datePicker"
        />


</RelativeLayout>

Any help would be great!


Solution

  • I realized that in my ToDoView class, I was missing the constructor:

    public ToDoView(Context c, AtrributeSet as){
        super(c, as);
        //...
    }
    

    Found at https://stackoverflow.com/a/3739853/1888585