@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); } }
@Override public void setDrawSelectorOnTop(boolean onTop) { super.setDrawSelectorOnTop(onTop); drawSelectorOnTop = onTop; if (frame != null) { frame.setDrawSelectorOnTop(drawSelectorOnTop); } }