Getchildview Gets Not Called
I have searched similar threads but they didn't help me and they were light different or they still are unanswered, so I'll describe my trouble. I have an ExpandableListView with a
Solution 1:
Solved
In my first level Adapter (An adapter for the first level ExpandableListView
) I modified the getChildView
Method
...
// Member Fieldprivate ExpandableListView expandable_field_list;
...
@Overridepublic View getChildView(int groupPosition, int childPosition,boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stubif ( groupPosition == 1 ) {
if ( expandable_field_list == null ) {
expandable_field_list = newCustomExpandableListView(context);
// Here I initialize the second and third Level
client_adapter = newClientAdapter(context, groups, children);
expandable_field_list.setAdapter(client_adapter);
} else {
client_adapter.notifyDataSetChanged();
}
convertView = expandable_field_list;
}
return convertView;
}
...
And CustomExpandableListView
looks like this
publicclassCustomExpandableListViewextendsExpandableListView {
privatebooleanexpanded=true;
publicCustomExpandableListView(Context context) {
super(context);
}
@OverridepublicvoidonMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isExpanded()) {
// View.MEASURED_SIZE_MASK represents the largest height possible.intexpandSpec= MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParamsparams= getLayoutParams();
params.height = getMeasuredHeight();
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@OverrideprotectedvoidonDetachedFromWindow() {
try {
super.onDetachedFromWindow();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
publicvoidsetIsExpanded(boolean expanded) {
this.expanded = expanded;
}
publicbooleanisExpanded() {
return expanded;
}
}
That is its aspect now as desired
Post a Comment for "Getchildview Gets Not Called"