@Override
 protected void drawableStateChanged() {
   super.drawableStateChanged();
   if (mHeaderView != null) {
     refreshAllChild(mHeaderView);
   }
 }
 @Override
 protected void dispatchDraw(Canvas canvas) {
   super.dispatchDraw(canvas);
   if (mHeaderView != null && mHeaderView.getVisibility() == View.VISIBLE) {
     drawChild(canvas, mHeaderView, getDrawingTime());
   }
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (mHeaderView != null) {
     measureChild(mHeaderView, widthMeasureSpec, heightMeasureSpec);
   }
 }
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   super.onLayout(changed, left, top, right, bottom);
   if (mHeaderView != null) {
     configHeaderView(getFirstVisiblePosition());
   }
   if (mOnLayoutListener != null) {
     mOnLayoutListener.onLayout(this, left, top, right, bottom);
   }
 }
 @Override
 public void setAdapter(android.widget.ExpandableListAdapter adapter) {
   super.setAdapter(adapter);
   if (adapter instanceof ExpandableListAdapter) {
     mAdapter = (ExpandableListAdapter) adapter;
     int headerViewLayoutId = mAdapter.getHeaderViewLayoutResourceId();
     if (headerViewLayoutId != 0) {
       mHeaderView = LayoutInflater.from(mContext).inflate(headerViewLayoutId, this, false);
       if (mHeaderView != null) {
         mHeaderView.setOnTouchListener(
             new View.OnTouchListener() {
               @Override
               public boolean onTouch(View v, MotionEvent e) {
                 if (e.getAction() == MotionEvent.ACTION_UP) {
                   long pos = getExpandableListPosition(getFirstVisiblePosition());
                   if (getPackedPositionType(pos)
                           == PinnedHeaderExpandableListView.PACKED_POSITION_TYPE_GROUP
                       || getPackedPositionType(pos)
                           == PinnedHeaderExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                     int groupPosition = getPackedPositionGroup(pos);
                     if (mOnGroupClickedListener == null
                         || !mOnGroupClickedListener.onGroupClick(
                             PinnedHeaderExpandableListView.this,
                             v,
                             groupPosition,
                             mAdapter.getGroupId(groupPosition))) {
                       PinnedHeaderExpandableListView.this.collapseGroup(groupPosition);
                     }
                   }
                 }
                 return true;
               }
             });
       }
       requestLayout();
     }
   }
 }
 private void init(Context context) {
   mContext = context;
   super.setOnScrollListener(this);
 }
 @Override
 public void setOnGroupClickListener(OnGroupClickListener l) {
   mOnGroupClickedListener = l;
   super.setOnGroupClickListener(l);
 }