public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { GroupInfo info = GetGroupInfo(groupPosition); if (info.animating) { // If this group is animating, return the a DummyView... if (convertView is DummyView == false) { convertView = new DummyView(parent.Context); convertView.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, 0); } if (childPosition < info.firstChildPosition) { convertView.LayoutParameters.Height = 0; return(convertView); } ExpandableListView listView = (ExpandableListView)parent; DummyView dummyView = (DummyView)convertView; // Clear the views that the dummy view draws. dummyView.ClearViews(); // Set the style of the divider dummyView.SetDivider(listView.Divider, parent.MeasuredWidth, listView.DividerHeight); // Make measure specs to measure child views int measureSpecW = MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly); int measureSpecH = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified); int totalHeight = 0; int clipHeight = parent.Height; int len = GetRealChildrenCount(groupPosition); for (int i = info.firstChildPosition; i < len; i++) { View childView = GetRealChildView(groupPosition, i, (i == len - 1), null, parent); LayoutParams p = (LayoutParams)childView.LayoutParameters; if (p == null) { p = (LayoutParams)GenerateDefaultLayoutParams(); childView.LayoutParameters = p; } int lpHeight = p.Height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly); } else { childHeightSpec = measureSpecH; } childView.Measure(measureSpecW, childHeightSpec); totalHeight += childView.MeasuredHeight; if (totalHeight < clipHeight) { // we only need to draw enough views to fool the user... dummyView.AddFakeView(childView); } else { dummyView.AddFakeView(childView); // if this group has too many views, we don't want to // calculate the height of everything... just do a light // approximation and break int averageHeight = totalHeight / (i + 1); totalHeight += (len - i - 1) * averageHeight; break; } } int state; if (dummyView.Tag == null) { state = STATE_IDLE; } else { state = ((Integer)dummyView.Tag).IntValue(); } if (info.expanding && state != STATE_EXPANDING) { ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info); ani.Duration = ANIMATION_DURATION; ExpandableAnimationListener expandAnimationListener = new ExpandableAnimationListener(this, state, groupPosition, dummyView, listView, info); ani.SetAnimationListener(expandAnimationListener); dummyView.StartAnimation(ani); dummyView.Tag = STATE_EXPANDING; } else if (!info.expanding && state != STATE_COLLAPSING) { if (info.dummyHeight == -1) { info.dummyHeight = totalHeight; } ExpandAnimation ani = new ExpandAnimation(dummyView, info.dummyHeight, 0, info); ani.Duration = ANIMATION_DURATION; ExpandableAnimationListener collapseAnimationListener = new ExpandableAnimationListener(this, state, groupPosition, dummyView, listView, info); ani.SetAnimationListener(collapseAnimationListener); dummyView.StartAnimation(ani); dummyView.Tag = STATE_COLLAPSING; } return(convertView); } else { return(GetRealChildView(groupPosition, childPosition, isLastChild, convertView, parent)); } }