views:

34

answers:

1

Hi,

I would like to change text and back ground color of my Listview without building custom rows. Is this possible ?

Here is my code which is NOT working.

android:layout_width="fill_parent" android:layout_height="fill_parent" android:cacheColorHint="#000000"/>

Any help would be appreciated.

Thank you

A: 

First of all, cacheColorHint has nothing to do with style. Try watching Romain Guy's ListView presentation on the GoogleIO 2010. You will understand a lot with it.

About the style:

I have changed a few things on my app.

View with the ListView:

<ListView android:id="@id/android:list"
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:layout_weight="1"
  android:headerDividersEnabled="false"
  android:footerDividersEnabled="true"
  android:divider="@drawable/list_divider"
  android:dividerHeight="1dip"
  android:cacheColorHint="#FFFFFF"
/>

Short explanation: I just left the footerDivider and changed my divider to a gradient.

drawable/list_divider:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <item>
        <shape>
            <gradient
                android:startColor="#000000"
                android:centerColor="#CCCCCC"
                android:endColor="#FFFFFF"
                android:height="1px"
                android:angle="0" />
        </shape>
    </item>
</layer-list>

RowLayout:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@android:color/white">

Explanation: Added a white background.

Macarse