コード例 #1
0
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      ViewGroup item;

      if (convertView != null && convertView.getId() == R.id.child_item) {
        // We can reuse the view
        item = (ViewGroup) convertView;
      } else {
        // We create a new View
        item = (ViewGroup) inflater.inflate(R.layout.child_item_layout, parent, false);
      }

      ChildClass child = (ChildClass) getChild(groupPosition, childPosition);

      TextView nameView = (TextView) item.findViewById(R.id.child_name);
      nameView.setText(child.getName());

      TextView sizeView = (TextView) item.findViewById(R.id.child_text);
      sizeView.setText(child.getText());

      return item;
    }