简体   繁体   中英

Set style for Expandable List

I want to set new style for expandable list view in my Android app. I am creating a group_indicator.xml file in drawable folder, where I am writing the code:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_empty="true" android:drawable="@drawable/arrowright1">
    <item android:state_expanded="true" android:drawable="@drawable/arrowdown1">
    <item android:drawable="@drawable/arrowright1">
</item></item></item></selector>

Then I am using this XML file in my ExpandableList view in the main file:

<ExpandableListView
        android:id="@+id/android:list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:groupIndicator="@drawable/group_indicator"
        android:layout_weight="1" >
    </ExpandableListView>

Now I want to set some more styles for my expandable list, I want to change the appearance of the parent and the child nodes.

Is there any other way to do that? I heard of some style.xml file in res->values folder, but I don't know exactly how to implement it. Please Guide.

You need to use implement custom ExpandableListAdapter

Override the following methods:

getChildView to override child view and inflate your own custom view. getGroupView to override group header view and inflate your own custom view.

Use the ExpandableListView#setGroupIndicator(Drawable) method. it worked for me. hope it wil help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM