Android dropdown icon

I want to add an image icon to an extensible list view. I saw a tutorial that they added only to children. Is there any other way to add an image icon to the parent Any help would be greatly appreciated. Thanks in advance.

+6
java android
source share
4 answers

You can try the setGroupIndicator(Drawable) method for ExpandableListView.

+5
source share

You can also define your own group id in XML:

First define your own drawable (I named it list_view_group_indicator.xml and put it in the drop down directory)

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_expanded="true" android:drawable="@drawable/packagexgeneric" /> <item android:drawable="@drawable/packagexgenericclose" /> </selector> 

Then use it as pullable for your expandableListview

 <ExpandableListView android:id="@+id/server_show_list" android:layout_width="fill_parent"android:layout_height="wrap_content" android:groupIndicator="@drawable/list_view_group_indicator" /> 
+13
source share

ok

  public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { if(getChildrenCount(groupPosition)==0) { // how do i hide the group indicator ? } 

So, how to change the group indicator for empty groups?

+1
source share
  indicator=(ImageView)convertView.findViewById(R.id.icon_img); if ( getChildrenCount( groupPosition ) == 0 ) { indicator.setVisibility( View.INVISIBLE ); } else { indicator.setVisibility( View.VISIBLE ); indicator.setImageResource( isExpanded ? R.drawable.ic_arrow_up : R.drawable.ic_arrow_down ); } 
0
source share

All Articles