title: How to add a "header" view at the top of each expanded group view in an ExpandableListView populated by SimpleCursorAdapter
body: <p>I'm using an ExpandableListView inside one of my activities and populating the child and group views (separate .xml files with a few textviews for each) using a custom SimpleCursorAdapter. I'm looking to have the following functionality: When a group is clicked, the list of children populates and an additional header (two textviews) populates in position 0 of the child list to act as the titles of each column of data the child displays. </p>
  
  <p>Here's the code for my SimpleCursorAdapter and a snippet of the relevant code in my activity:</p>
  
  <p>SimpleCursorAdapter:</p>
  
  <pre><code>public class PayeeCursorAdapter extends SimpleCursorTreeAdapter {
  
  private final String LOG_TAG = getClass().getSimpleName();
  private PayeeActivity mActivity;
  protected final HashMap&lt;Integer, Integer&gt; mGroupMap;
  
  // No cursor is added to the adapter so that it only runs when the CursorLoader runs, instead of every time the activity does
  public PayeeCursorAdapter(
          Context context,        // The activity where the adapter will be running
          int groupLayout,        // The .xml layout file for the group layout
          int childLayout,        // The .xml layout file for the child layout
          String[] groupFrom,     // String of column names in the cursor that is the data for each group item
          int[] groupTo,          // The ID of the views in the group layout that display the column from the groupFrom String[]
          String[] childrenFrom,  // String of column names in the cursor that is the data for each child item
          int[] childrenTo) {     // The ID of the views in the child layout that display the column from the childFrom String[]
  
      super(context, null, groupLayout, groupFrom, groupTo, childLayout, childrenFrom, childrenTo);
      mActivity = (PayeeActivity) context;
      mGroupMap = new HashMap&lt;Integer, Integer&gt;();
  }
  @Override
  protected Cursor getChildrenCursor(Cursor groupCursor) {
  
      int groupPos = groupCursor.getPosition();
      int groupId = groupCursor.getInt(groupCursor.getColumnIndex(BillMeContract.PayeeEntry._ID));
  
      Log.d(LOG_TAG, "getChildrenCursor() for groupPos " + groupPos);
      Log.d(LOG_TAG, "getChildrenCursor() for groupId " + groupId);
  
      mGroupMap.put(groupId, groupPos);
      Loader&lt;Cursor&gt; loader = mActivity.getSupportLoaderManager().getLoader(groupId);
  
      if(loader != null &amp;&amp; !loader.isReset()) {
          mActivity.getSupportLoaderManager().restartLoader(groupId, null, mActivity);
      } else {
          mActivity.getSupportLoaderManager().initLoader(groupId, null, mActivity);
      }
      return null;
  }
  
  public HashMap&lt;Integer, Integer&gt; getGroupMap(){
      return mGroupMap;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Activity:</p>
  
  <pre><code>ExpandableListView expandablePayeeListView = (ExpandableListView) findViewById(R.id.payee_exp_list);
  
      mAdapter = new PayeeCursorAdapter(
              this,
              R.layout.list_group_payee,
              R.layout.list_item_payee_tx,
              new String[] {BillMeContract.PayeeEntry.COL_NAME},
              new int[] {R.id.payee_list_header},
              new String[] {BillMeContract.TransactionEntry.COL_DATE,
                            BillMeContract.TransactionEntry.COL_PAYMENT,
                            BillMeContract.TransactionEntry.COL_TYPE},
              new int[] {R.id.payee_list_item_date,
                         R.id.payee_list_item_amount,
                         R.id.payee_list_item_type});
  
      mAdapter.setViewBinder(new SimpleCursorTreeAdapter.ViewBinder() {
  
          public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
  
              if(columnIndex == 4) {
                  int type = cursor.getInt(columnIndex);
                  TextView textView = (TextView) view;
                  if(type == BillMeContract.TransactionEntry.TYPE_CASH) {
                      textView.setText(R.string.tx_spinner_type_cash);
                  } else if (type == BillMeContract.TransactionEntry.TYPE_CHEQUE) {
                      textView.setText(R.string.tx_spinner_type_cheque);
                  } else if (type == BillMeContract.TransactionEntry.TYPE_E_TRANSFER) {
                      textView.setText(R.string.tx_spinner_type_e_transfer);
                  }
                  return true;
              } else if(columnIndex == 3){
                  String cost = String.format(Locale.CANADA, "%.2f", cursor.getDouble(columnIndex));
                  cost = "$" + cost;
                  TextView textView = (TextView) view;
                  textView.setText(cost);
                  return true;
              }
              return false;
          }
      });
  
      expandablePayeeListView.setAdapter(mAdapter);
  </code></pre>