content: package com.example.anan.AAChartCore.ChartsDemo.MainContent;
  
  import android.content.Context;
  import android.graphics.Color;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseExpandableListAdapter;
  import android.widget.TextView;
  
  import com.example.anan.AAChartCore.R;
  
  public class MyBaseExpandableListAdapter extends BaseExpandableListAdapter {
  
      private String[] gData;
      private String[][] iData;
      private Context mContext;
      private String[] colorsArr = new String[]{
              "#5470c6",
              "#91cc75",
              "#fac858",
              "#ee6666",
              "#73c0de",
              "#3ba272",
              "#fc8452",
              "#9a60b4",
              "#ea7ccc",
  
              "#5470c6",
              "#91cc75",
              "#fac858",
              "#ee6666",
              "#73c0de",
              "#3ba272",
              "#fc8452",
              "#9a60b4",
              "#ea7ccc",
      };
  
      public MyBaseExpandableListAdapter(String[] gData, String[][] iData, Context mContext) {
          this.gData = gData;
          this.iData = iData;
          this.mContext = mContext;
      }
  
      @Override
      public int getGroupCount() {
          return gData.length;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          return iData[groupPosition].length;
      }
  
      @Override
      public String getGroup(int groupPosition) {
         return gData[groupPosition];
      }
  
      @Override
      public String getChild(int groupPosition, int childPosition) {
          return iData[groupPosition][childPosition];
      }
  
      @Override
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      @Override
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
      @Override
      public boolean hasStableIds() {
          return false;
      }
  
      //取得用于显示给定分组的视图. 这个方法仅返回分组的视图对象
      @Override
      public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
  
          ViewHolderGroup groupHolder;
          if(convertView == null){
              convertView = LayoutInflater.from(mContext).inflate(
                      R.layout.item_exlist_group, parent, false);
              groupHolder = new ViewHolderGroup();
              groupHolder.tv_group_name = (TextView) convertView.findViewById(R.id.tv_group_name);
              convertView.setTag(groupHolder);
          }else{
              groupHolder = (ViewHolderGroup) convertView.getTag();
          }
          groupHolder.tv_group_name.setText(gData[groupPosition]);
          return convertView;
      }
  
      //取得显示给定分组给定子位置的数据用的视图
      @Override
      public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
          ViewHolderItem itemHolder;
          if(convertView == null){
              convertView = LayoutInflater.from(mContext).inflate(
                      R.layout.item_exlist_item, parent, false);
              itemHolder = new ViewHolderItem();
              itemHolder.tv_color_dot = (TextView) convertView.findViewById(R.id.tv_colorful_index);
              itemHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
              convertView.setTag(itemHolder);
          }else{
              itemHolder = (ViewHolderItem) convertView.getTag();
          }
          String colorStr = colorsArr[groupPosition];
          itemHolder.tv_color_dot.setTextColor(Color.parseColor(colorStr));
  //        itemHolder.tv_color_dot.setBackgroundColor(Color.parseColor(colorStr));
          itemHolder.tv_color_dot.setText((childPosition + 1) + "");
          itemHolder.tv_name.setText(iData[groupPosition][childPosition]);
  
          return convertView;
      }
  
      //设置子列表是否可选中
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  
  
      private static class ViewHolderGroup{
          private TextView tv_group_name;
      }
  
      private static class ViewHolderItem{
          private TextView tv_color_dot;
          private TextView tv_name;
      }
  
  }
  