i want to implement expandable list view with multiple child layouts. all works fine but problem om,child view..child not appear on appropriate position.... here is my code...PL
I have done this by add and remove the header view under the parent group layout.
If you group layout is a LinearLayout that have orientation="vertical" like this
I add a references to the ExpandableListView in my constructor for my ExpandListAdapter so I can check if the group is expanded
private ExpandableListView list;
public ExpandListAdapter(Context context, ArrayList groups, ExpandableListView list) {
this.list = list;
}
and then in top of the method getGroupView check if it is expandet and add or if it is not remove
public View getGroupView(int groupPosition, boolean isLastChild, View view, ViewGroup parent) {
final Group group = getGroup(groupPosition);
LayoutInflater inf = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inf.inflate(R.layout.group_list_row, null);
final View childheader = inf.inflate(R.layout.child_list_header, null);
LinearLayout groupLayout = (LinearLayout) view.findViewById(R.id.group_layout_id);
if(list.isGroupExpanded(groupPosition)){
groupLayout.addView(childheader, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
}else{
groupLayout.removeView(childheader);
}