@Override
 public void setSelector(Drawable sel) {
   super.setSelector(sel);
   if (frame != null) {
     frame.setSelector(sel);
   }
 }
  @SuppressWarnings("deprecation")
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (frame == null) {
      ViewGroup parent = ((ViewGroup) getParent());
      int listIndex = parent.indexOfChild(this);
      parent.removeView(this);

      int visibility = getVisibility();
      setVisibility(View.VISIBLE);

      frame = new StickyListHeadersListViewWrapper(getContext());
      frame.setSelector(getSelector());
      frame.setDrawSelectorOnTop(drawSelectorOnTop);
      frame.setVisibility(visibility);

      ViewGroup.MarginLayoutParams p = (MarginLayoutParams) getLayoutParams();
      if (clippingToPadding) {
        frame.setPadding(0, getPaddingTop(), 0, getPaddingBottom());
        setPadding(getPaddingLeft(), 0, getPaddingRight(), 0);
      }

      ViewGroup.LayoutParams params =
          new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      setLayoutParams(params);

      frame.addView(this);
      frame.setBackgroundDrawable(getBackground());
      super.setBackgroundDrawable(null);

      frame.setLayoutParams(p);
      parent.addView(frame, listIndex);
    }
  }