@TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public StickyListHeadersListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Initialize the list
    mList = new WrapperViewList(context);
    mDivider = mList.getDivider();
    mDividerHeight = mList.getDividerHeight();

    // null out divider, dividers are handled by adapter so they look good
    // with headers
    mList.setDivider(null);
    mList.setDividerHeight(0);

    mList.setLifeCycleListener(new WrapperViewListLifeCycleListener());
    mList.setOnScrollListener(new WrapperListScrollListener());
    addView(mList);

    if (attrs != null) {
      TypedArray a =
          context
              .getTheme()
              .obtainStyledAttributes(attrs, R.styleable.StickyListHeadersListView, 0, 0);

      try {
        // Android attributes
        if (a.hasValue(R.styleable.StickyListHeadersListView_android_padding)) {
          int padding =
              a.getDimensionPixelSize(R.styleable.StickyListHeadersListView_android_padding, 0);
          mPaddingLeft = padding;
          mPaddingTop = padding;
          mPaddingRight = padding;
          mPaddingBottom = padding;
        } else {
          mPaddingLeft =
              a.getDimensionPixelSize(R.styleable.StickyListHeadersListView_android_paddingLeft, 0);
          mPaddingTop =
              a.getDimensionPixelSize(R.styleable.StickyListHeadersListView_android_paddingTop, 0);
          mPaddingRight =
              a.getDimensionPixelSize(
                  R.styleable.StickyListHeadersListView_android_paddingRight, 0);
          mPaddingBottom =
              a.getDimensionPixelSize(
                  R.styleable.StickyListHeadersListView_android_paddingBottom, 0);
        }
        setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);

        // Set clip to padding on the list and reset value to default on
        // wrapper
        mClippingToPadding =
            a.getBoolean(R.styleable.StickyListHeadersListView_android_clipToPadding, true);
        super.setClipToPadding(true);
        mList.setClipToPadding(mClippingToPadding);

        // ListView attributes
        mList.setFadingEdgeLength(
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_fadingEdgeLength,
                mList.getVerticalFadingEdgeLength()));
        final int fadingEdge =
            a.getInt(R.styleable.StickyListHeadersListView_android_requiresFadingEdge, 0);
        if (fadingEdge == 0x00001000) {
          mList.setVerticalFadingEdgeEnabled(false);
          mList.setHorizontalFadingEdgeEnabled(true);
        } else if (fadingEdge == 0x00002000) {
          mList.setVerticalFadingEdgeEnabled(true);
          mList.setHorizontalFadingEdgeEnabled(false);
        } else {
          mList.setVerticalFadingEdgeEnabled(false);
          mList.setHorizontalFadingEdgeEnabled(false);
        }
        mList.setCacheColorHint(
            a.getColor(
                R.styleable.StickyListHeadersListView_android_cacheColorHint,
                mList.getCacheColorHint()));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
          mList.setChoiceMode(
              a.getInt(
                  R.styleable.StickyListHeadersListView_android_choiceMode, mList.getChoiceMode()));
        }
        mList.setDrawSelectorOnTop(
            a.getBoolean(R.styleable.StickyListHeadersListView_android_drawSelectorOnTop, false));
        mList.setFastScrollEnabled(
            a.getBoolean(
                R.styleable.StickyListHeadersListView_android_fastScrollEnabled,
                mList.isFastScrollEnabled()));
        mList.setScrollBarStyle(
            a.getInt(R.styleable.StickyListHeadersListView_android_scrollbarStyle, 0));
        final Drawable selector =
            a.getDrawable(R.styleable.StickyListHeadersListView_android_listSelector);
        if (selector != null) {
          mList.setSelector(selector);
        }
        mList.setScrollingCacheEnabled(
            a.getBoolean(
                R.styleable.StickyListHeadersListView_android_scrollingCache,
                mList.isScrollingCacheEnabled()));
        final Drawable divider =
            a.getDrawable(R.styleable.StickyListHeadersListView_android_divider);
        if (divider != null) {
          mDivider = divider;
        }
        mDividerHeight =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_dividerHeight, mDividerHeight);

        // StickyListHeaders attributes
        mAreHeadersSticky =
            a.getBoolean(R.styleable.StickyListHeadersListView_hasStickyHeaders, true);
        mIsDrawingListUnderStickyHeader =
            a.getBoolean(
                R.styleable.StickyListHeadersListView_isDrawingListUnderStickyHeader, true);

      } finally {
        a.recycle();
      }
    }
  }
 public void setSelector(Drawable sel) {
   mList.setSelector(sel);
 }
 public void setSelector(int resID) {
   mList.setSelector(resID);
 }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public StickyListHeadersListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    // Initialize the wrapped list
    mList = new WrapperViewList(context);

    // null out divider, dividers are handled by adapter so they look good with headers
    mDivider = mList.getDivider();
    mDividerHeight = mList.getDividerHeight();
    mList.setDivider(null);
    mList.setDividerHeight(0);

    if (attrs != null) {
      TypedArray a =
          context
              .getTheme()
              .obtainStyledAttributes(attrs, R.styleable.StickyListHeadersListView, defStyle, 0);

      try {
        // -- View attributes --
        int padding =
            a.getDimensionPixelSize(R.styleable.StickyListHeadersListView_android_padding, 0);
        mPaddingLeft =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_paddingLeft, padding);
        mPaddingTop =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_paddingTop, padding);
        mPaddingRight =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_paddingRight, padding);
        mPaddingBottom =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_paddingBottom, padding);

        setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);

        // Set clip to padding on the list and reset value to default on
        // wrapper
        mClippingToPadding =
            a.getBoolean(R.styleable.StickyListHeadersListView_android_clipToPadding, true);
        super.setClipToPadding(true);
        mList.setClipToPadding(mClippingToPadding);

        // scrollbars
        final int scrollBars =
            a.getInt(R.styleable.StickyListHeadersListView_android_scrollbars, 0x00000200);
        mList.setVerticalScrollBarEnabled((scrollBars & 0x00000200) != 0);
        mList.setHorizontalScrollBarEnabled((scrollBars & 0x00000100) != 0);

        // overscroll
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
          mList.setOverScrollMode(
              a.getInt(R.styleable.StickyListHeadersListView_android_overScrollMode, 0));
        }

        // -- ListView attributes --
        mList.setFadingEdgeLength(
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_fadingEdgeLength,
                mList.getVerticalFadingEdgeLength()));
        final int fadingEdge =
            a.getInt(R.styleable.StickyListHeadersListView_android_requiresFadingEdge, 0);
        if (fadingEdge == 0x00001000) {
          mList.setVerticalFadingEdgeEnabled(false);
          mList.setHorizontalFadingEdgeEnabled(true);
        } else if (fadingEdge == 0x00002000) {
          mList.setVerticalFadingEdgeEnabled(true);
          mList.setHorizontalFadingEdgeEnabled(false);
        } else {
          mList.setVerticalFadingEdgeEnabled(false);
          mList.setHorizontalFadingEdgeEnabled(false);
        }
        mList.setCacheColorHint(
            a.getColor(
                R.styleable.StickyListHeadersListView_android_cacheColorHint,
                mList.getCacheColorHint()));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
          mList.setChoiceMode(
              a.getInt(
                  R.styleable.StickyListHeadersListView_android_choiceMode, mList.getChoiceMode()));
        }
        mList.setDrawSelectorOnTop(
            a.getBoolean(R.styleable.StickyListHeadersListView_android_drawSelectorOnTop, false));
        mList.setFastScrollEnabled(
            a.getBoolean(
                R.styleable.StickyListHeadersListView_android_fastScrollEnabled,
                mList.isFastScrollEnabled()));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
          mList.setFastScrollAlwaysVisible(
              a.getBoolean(
                  R.styleable.StickyListHeadersListView_android_fastScrollAlwaysVisible,
                  mList.isFastScrollAlwaysVisible()));
        }

        mList.setScrollBarStyle(
            a.getInt(R.styleable.StickyListHeadersListView_android_scrollbarStyle, 0));

        if (a.hasValue(R.styleable.StickyListHeadersListView_android_listSelector)) {
          mList.setSelector(
              a.getDrawable(R.styleable.StickyListHeadersListView_android_listSelector));
        }

        mList.setScrollingCacheEnabled(
            a.getBoolean(
                R.styleable.StickyListHeadersListView_android_scrollingCache,
                mList.isScrollingCacheEnabled()));

        if (a.hasValue(R.styleable.StickyListHeadersListView_android_divider)) {
          mDivider = a.getDrawable(R.styleable.StickyListHeadersListView_android_divider);
        }

        mList.setStackFromBottom(
            a.getBoolean(R.styleable.StickyListHeadersListView_android_stackFromBottom, false));

        mDividerHeight =
            a.getDimensionPixelSize(
                R.styleable.StickyListHeadersListView_android_dividerHeight, mDividerHeight);

        mList.setTranscriptMode(
            a.getInt(
                R.styleable.StickyListHeadersListView_android_transcriptMode,
                ListView.TRANSCRIPT_MODE_DISABLED));

        // -- StickyListHeaders attributes --
        mAreHeadersSticky =
            a.getBoolean(R.styleable.StickyListHeadersListView_hasStickyHeaders, true);
        mIsDrawingListUnderStickyHeader =
            a.getBoolean(
                R.styleable.StickyListHeadersListView_isDrawingListUnderStickyHeader, true);
      } finally {
        a.recycle();
      }
    }

    // attach some listeners to the wrapped list
    mList.setLifeCycleListener(new WrapperViewListLifeCycleListener());
    mList.setOnScrollListener(new WrapperListScrollListener());

    addView(mList);
  }