Getting message in android app: Binary XML file line #2: You must supply a layout_width attribute.

Posted by opike on Stack Overflow See other posts from Stack Overflow or by opike
Published on 2011-01-12T22:47:01Z Indexed on 2011/01/12 22:53 UTC
Read the original article Hit count: 432

Filed under:
|

I'm trying to use a ListView inside of a RelativeLayout but when I run my app I get a runtimeexception with the message:

Binary XML file line #2: You must supply a layout_width attribute.

I tried putting layout_width attributes in every conceivable place in the xml resource files but so far no luck.

I attempt to populate the listview with this line of code:

   setListAdapter(new ArrayAdapter(this,
           R.layout.tablerow3, R.id.label,
           items));

Here's the tablerow3.xml contents:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
          android:layout_width="20dp"
          android:layout_height="5dp"
          android:id="@+id/tablerow01">
      <Label android:id="@+id/label01"
      android:layout_width="5dp"
  android:layout_height="5dp"
      android:textColor="@color/solid_white"
         android:singleLine="true"/>
      <Label android:id="@+id/label02"
      android:layout_width="5dp"
  android:layout_height="5dp"
         android:textColor="@color/solid_white"
         android:singleLine="true"/>
      </LinearLayout>

Here's the xml that contains the RelativeLayout(forex2.xml):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
   <Button android:text="Static Button"
      android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:id="@+id/button_id">
      </Button>

        <Spinner android:id="@+id/spinner1"
            android:layout_width="match_parent"
            android:layout_toRightOf="@id/button_id"
            android:layout_alignParentTop="true"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="true"

        />

    <ListView android:id="@android:id/list"  
 android:layout_width="5dp"
  android:layout_height="5dp"
  android:layout_alignParentBottom="true"
   />
   <!--  android:layout_width="wrap_content"
  android:layout_height="wrap_content" --> 
</RelativeLayout>

© Stack Overflow or respective owner

Related posts about java

Related posts about android