android – ListView divider not showing-ThrowExceptions

Exception or error:

I have a ListView with BaseAdapter. In XML, I specified item divider as red color with 10dip height.

    <ListView android:layout_width="fill_parent"
                android:layout_height="0px"
                android:id="@+id/lv"
                android:layout_weight="1"
                android:cacheColorHint="#00000000"
                android:divider="#FF0000"
                android:dividerHeight="10dip"
                android:fadingEdge="none">
    </ListView>

But, when the app runs, I didn’t see the red dividers between items. Can someone tell me why? Thanks.

Edit: in my adapter code, I have the following code:

@Override
public boolean areAllItemsEnabled() {
    return false;
}

@Override
public boolean isEnabled(int position) {
    return false;
}

because I want control the onClick behavior of each item. I don’t know whether the code above makes the dividers disappear.

How to solve:

The layout is good and it should work. I just tested it myself and it did work for me.
Try seeing what you have in your list item layout or your list activity class.

If that doesn’t work I would recommend creating a normal list from the samples and give the list these attributes and see what happened.

Achie.

Leave a Reply

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