I am using expandablelistview in my project,and I want to add different images for group view and also in child view I want to do same,but its not working,following is my co
You are trying to convert String to Integer
In your
ExpandableTests class
comment following lines
//in getChildView() method
// final int childimg = (Integer) getChild(groupPosition, childPosition);
//in getGroupView method
//String headerTitle = (String) getGroup(groupPosition);
And use any default icon for following images like
imgsListHeader.setImageResource(R.drawable.ic_launcher);
imgListChild.setImageResource(R.drawable.ic_launcher);
By this way you will get out of crash and hope you will get idea further image displaying.
Replace following line with previous one in getChildView
final int childimg = _Child.get(groupPosition).get(childPosition);
imgListChild.setImageResource(childimg);
Replace following line with previous one in getGroupView
int headerimg = _group.get(groupPosition);
imgsListHeader.setImageResource(headerimg);
Replace following line MainActivity
listAdapter = new ExpandableTests(this, listDataHeader, groupImages, listDataChild, childImages);
Add one more image in
groupImages arraylist in prepareListData method
Replace following lines
childImages.put(groupImages.get(0), Maincat);
childImages.put(groupImages.get(1), subcat);
To
childImages.put(0, Maincat);
childImages.put(1, subcat);
For Indicator icon
Add following line in getGroupView() in ExpandableTests
ImageView imgIndicator = (ImageView) convertView.findViewById(R.id.indicator);
if (isExpanded) {
imgIndicator.setImageResource(R.drawable.minus);
} else {
imgIndicator.setImageResource(R.drawable.plus);
}
Add following imageview in list_group.xml
<ImageView
android:id="@+id/indicator"
android:layout_width="24sp"
android:layout_height="24sp"
android:layout_alignParentRight="true"
/>