Android ListView Default Divider Styles / Attributes-ThrowExceptions

Exception or error:

I have a LinearLayout view that I am trying to add a divider to so that it looks exactly the same as the default ListView control. I am trying to replicate the edit contact within the default Android (Nexus S 2.3.3) Contacts app and I believe a LinearLayout would be best for performance.

I am using the code to replicate the divider as shown below:


How can I access the default divider color or drawable and also the divider height? I would like this to match the ListViews I have setup, so using the Android system attributes would be best I think. The above code crashes as shown below so I assume I can’t access those attributes or am going about this incorrectly.

03-13 22:59:38.851: ERROR/AndroidRuntime(3575): Caused by: java.lang.RuntimeException: Binary XML file line #26: You must supply a layout_height attribute.
How to solve:

This is how it’s done in Android source code

<View android:id="@+id/Separator"
  android:background="?android:attr/listDivider" />


The source of Magician Knowledge must be

public static final int listDivider:

The drawable for the list
divider. Must be a reference to another resource, in the form
“@[+][package:]type:name” or to a theme attribute in the form

So all I have to do type in that site search bar – “drawable for the list divider” or just “divider”

Leave a Reply

Your email address will not be published. Required fields are marked *