Domanda

I am having the following ExpandableListView:

<ExpandableListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/listView"
            android:groupIndicator="@android:color/transparent"
            android:background="@color/app_background"
            android:scrollingCache="false"
            android:choiceMode="none"
            android:divider="@color/gray_dark"
            android:dividerHeight="2dp"
            android:childDivider="@color/gray_dark"
            android:cacheColorHint="@color/app_background"/>

The problem that I have is that the expandable list view is not drawing the dividers or at least are not visible.. I am adding a custom view as Group view and also custom list items in my expandable adapter. Could this be a problem?

Does anyone know what can I do to enable the dividers for the list child?

Thank you in advance.

È stato utile?

Soluzione

It seems that I had an issue on my Expandable Adapter.. I was overridden the following method:

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

Instead of returning true I left the method to return false and that was the problem... So if anyone has this problem, check that method and make sure it returns true and not false.

Note that it is not necessary to override that method if you extend BaseExpandableListAdapter

Altri suggerimenti

I've never tried to mess with the dividers in the xml, I've always done it through code. Following is a snippet that sets the divider to red and has it fade out as it moves form the center to the edges. There is only one divider height call as that part affects both the group and the child.

import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;

// code to set up expandablelistview

int[] colors = {0, 0xFFFF0000, 0}; // red for the example 
getListView().setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); 
getListView().setChildDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); 
getListView().setDividerHeight(4); 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top