开发者

Android: Tablelayout with relative layouts contained within?

I have an xml layout that compiles fine but when I used the intent to change to the new view it force closes. I'm almost positive it has to do with my use of table and relative layouts. It's kind of a frankenstien monster of coding, haha. Please let me know if how I can remedy this force close problem. Also, before I had strickly table layout. With this layout it compiled and was fully functional, just not as a pretty. So the java should be fine (theoretically).

CODE:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/tableLayout1"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" android:background="#FFFFF0">
    <RelativeLayout android:orientation="vertical" android:background="@drawable/banner"
        android:layout_width="fill_parent" androi开发者_运维技巧d:layout_height="50sp" android:gravity="center" >

    </RelativeLayout>
    <RelativeLayout android:id="@+id/tableTitle" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:background="#999">
        <TextView android:id="@+id/ListingsTitle" android:text="Title: "
            android:textColor="#000" android:textStyle="bold" android:textSize="20sp" />
            <TextView android:id="@+id/sellingprice" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textColor="#000fff"
            android:text="Price:" android:layout_below="@id/ListingsTitle" ></TextView>
        <TextView android:id="@+id/mileage" android:layout_below="@id/ListingsTitle" android:layout_toRightOf="@id/sellingprice" android:layout_height="wrap_content" android:text="Mileage:" android:textColor="#000fff" android:layout_width="wrap_content"></TextView>

    </RelativeLayout>
    <RelativeLayout android:orientation="vertical" android:background="#FFFFF0"
        android:layout_width="fill_parent" android:layout_height="wrap_content">

        <ImageButton android:id="@+id/PhotoGallerybtn" 
            android:src="@drawable/icon" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_alignParentLeft="true"></ImageButton>

        <Button android:text="Email the Dealer" android:id="@+id/EmailDealerbtn" android:layout_alignParentLeft="true"
            android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/PhotoGallerybtn"></Button>
        <Button android:text="Add to Favs" android:id="@+id/Favsbtn" android:layout_below="@id/PhotoGallerybtn"
            android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/EmailDealerbtn"></Button>
        <Button android:text="Share" android:id="@+id/Sharebtn" android:mimeType="image/*"
            android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/PhotoGallerybtn" android:layout_toRightOf="@id/Favsbtn"></Button>




        </RelativeLayout>

    <TableRow android:id="@+id/tableRow4" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#999">

        <TextView android:id="@+id/textName" android:text="Details:"
            android:textColor="#000" android:textStyle="bold" android:textSize="20sp" />



    </TableRow>


    <TextView android:id="@+id/bodystyle" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textColor="#000"
        android:text="Body Style:"></TextView>
    <TextView android:id="@+id/color" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textColor="#000"
        android:text="Color:"></TextView>
    <TextView android:id="@+id/doors" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textColor="#000"
        android:text="Doors:"></TextView>
    <TextView android:id="@+id/engine" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textColor="#000"
        android:text="Engine:"></TextView>
    <TextView android:id="@+id/vin" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textColor="#000"
        android:text="VIN:"></TextView>
</TableLayout>


You should add layout_width and layout_height fields to your TextView with @+id/ListingsTitle id:

<TextView android:id="@+id/ListingsTitle" android:text="Title: "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000" 
        android:textStyle="bold" 
        android:textSize="20sp" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜