varghesekutty
varghesekutty

Reputation: 205

Hide exapandable list view icon with zero child size

I am developing an app which uses custom expandable list view. My icon changes when i click the list view. I don't want to add group indicator icon when the child size is zero. Please help

Thanks in advance

Upvotes: 0

Views: 224

Answers (1)

DSS
DSS

Reputation: 7259

This is of great help.

Code Snippets:

For state_empty, you can set a different image which is not confusing, or, simply use transparent color to display nothing...

Add this item in your stateful drawable along with others....

<item android:state_empty="true" android:drawable="@android:color/transparent"/>

So, your indicator can be like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_empty="true" android:drawable="@android:color/transparent"/>
    <item android:state_expanded="true" android:drawable="@drawable/my_icon_max" />
    <item android:drawable="@drawable/my_icon_min" />
</selector>

Explanation:

android:state_empty: - the element does not have any child
android:state_expanded: - state when it is expanded
android:drawable: - normal state, that is the cell has children but its not expanded

set the indicator like this:

getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.indicator));

Upvotes: 1

Related Questions