I want to add an image icon in expandable list view .I have seen the tutorial they have added only in child elements .Is there any other way to add image icon in parent Any hel
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 );
}
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 can modify the group indicator for empty groups ?
You can try the setGroupIndicator(Drawable)
method of ExpandableListView.
You can also define your own groupIndicator in XML:
First define your own drawable (I called it list_view_group_indicator.xml and placed it in the drawable 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 a drawable 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" />