AnimatedExpandableListView getGroupView
始终显示第0个位置,getCount
显示6
。并且它始终显示第0个位置值,并且不显示任何子项。任何人都建议我在下面的适配器源代码
这是我的代码:
private class MenuAdapter extends AnimatedExpandableListView.AnimatedExpandableListAdapter {
private LayoutInflater inflater;
ArrayList<HashMap<String, ArrayList<CategoryObj>>> subCatArrayList;
Context ct;
public MenuAdapter(Context context) {
inflater = LayoutInflater.from(context);
ct=context;
}
public void setData(ArrayList<HashMap<String, ArrayList<CategoryObj>>> catList) {
this.subCatArrayList = catList;
}
@Override
public HashMap<String, ArrayList<CategoryObj>> getChild(int groupPosition, int childPosition) {
return subCatArrayList.get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getRealChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ChildHolder holder;
if (convertView == null) {
holder = new ChildHolder();
convertView = inflater.inflate(R.layout.menu_sublist, parent, false);
holder.mMenu_SubCategory = (TextView) convertView.findViewById(R.id.subcat_item);
convertView.setTag(holder);
} else {
holder = (ChildHolder) convertView.getTag();
}
if(groupPosition == 0){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("A").get(childPosition).getSubCat_name());
}else if(groupPosition == 1){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("B").get(childPosition).getSubCat_name());
}else if(groupPosition == 2){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("C").get(childPosition).getSubCat_name());
}else if(groupPosition == 3){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("D").get(childPosition).getSubCat_name());
}else if(groupPosition == 4){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("E").get(childPosition).getSubCat_name());
}else if(groupPosition == 5){
holder.mMenu_SubCategory.setText(subCatArrayList.get(groupPosition).get("F").get(childPosition).getSubCat_name());
}
return convertView;
}
@Override
public int getRealChildrenCount(int groupPosition) {
return 2;
}
@Override
public HashMap<String, ArrayList<CategoryObj>> getGroup(int groupPosition) {
return subCatArrayList.get(groupPosition);
}
@Override
public int getGroupCount() {
Log.v("srinu", "group count:"+Globals.CatList().size());
return Globals.CatList().size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
GroupHolder holder;
if (convertView == null) {
holder = new GroupHolder();
convertView = inflater.inflate(R.layout.menu_categories, parent, false);
holder.mMenu_Category = (TextView) convertView.findViewById(R.id.cat_item);
convertView.setTag(holder);
} else {
holder = (GroupHolder) convertView.getTag();
}
holder.mMenu_Category.setText(Globals.CatList().get(groupPosition));
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int arg0, int arg1) {
return true;
}
}
private static class ChildHolder {
TextView mMenu_SubCategory;
}
private static class GroupHolder {
TextView mMenu_Category;
}