1:如果任何组没有项目,则它崩溃
2:如果只有一个组,则打开该组后仅显示一项。
public class AssignmentCompletedExpandableAdapter extends BaseExpandableListAdapter {
private List<String> _listDataHeader;
private HashMap<String, List<AssignmentScore>> _listDataChild;
public AssignmentCompletedExpandableAdapter( List<String> _listDataHeader,
HashMap<String, List<AssignmentScore>> _listDataChild ){
this._listDataHeader = _listDataHeader;
this._listDataChild = _listDataChild;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return _listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.size();
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
@Override
public View getChildView( int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
if( convertView == null ){
convertView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
inflate(R.layout.layout, null);
}
Data data = (Data ) getChild(groupPosition, childPosition);
TaggedView view = TaggedView.getTaggedView(convertView);
view .name_textView.setText(data.getName());
view .score_textView.setText(data.getScore());
return convertView;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if( convertView == null ){
convertView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
inflate(R.layout.layoutgroup, null);
}
TextView lblListHeader = (TextView)convertView.findViewById(R.id.groupname);
lblListHeader.setText((String)getGroup(groupPosition));
return convertView;
}
}