jueves, 27 de agosto de 2015

Android: Expandable list, group divider and child divider

Layout
<ExpandableListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:groupIndicator="@drawable/group_indicator_icon"
            android:divider="@color/orange"
            android:dividerHeight="1dp"
            android:childDivider="#b4b6b9"/>
Adapter
@Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    } // If it returns false the child divider won't appear
If you want to hide the group indicator for empty groups:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/transparent" android:state_expanded="true" android:state_empty="true" />
    <item android:state_expanded="true" android:drawable="@drawable/arrow_up" />
    <item android:drawable="@drawable/arrow_down" />
</selector>
Order is important, keep it as the example above.

No hay comentarios:

Publicar un comentario