private void removeNonVisibleViews(final int offset){
  int childCount=getChildCount();
  if (mLastItemPosition != mAdapter.getCount() - 1 && childCount > 1) {
    View firstChild=getChildAt(0);
    while (firstChild != null && getChildBottom(firstChild) + offset < 0) {
      removeViewInLayout(firstChild);
      childCount--;
      mCachedItemViews.addLast(firstChild);
      mFirstItemPosition++;
      mListTopOffset+=getChildHeight(firstChild);
      if (childCount > 1) {
        firstChild=getChildAt(0);
      }
 else {
        firstChild=null;
      }
    }
  }
  if (mFirstItemPosition != 0 && childCount > 1) {
    View lastChild=getChildAt(childCount - 1);
    while (lastChild != null && getChildTop(lastChild) + offset > getHeight()) {
      removeViewInLayout(lastChild);
      childCount--;
      mCachedItemViews.addLast(lastChild);
      mLastItemPosition--;
      if (childCount > 1) {
        lastChild=getChildAt(childCount - 1);
      }
 else {
        lastChild=null;
      }
    }
  }
}

private void removeNonVisibleViews ( final int offset ) { int childCount = getChildCount ( ) ; if ( mLastItemPosition != mAdapter . getCount ( ) - 1 && childCount > 1 ) { View firstChild = getChildAt ( 0 ) ; while ( firstChild != null && getChildBottom ( firstChild ) + offset < 0 ) { removeViewInLayout ( firstChild ) ; childCount -- ; mCachedItemViews . addLast ( firstChild ) ; mFirstItemPosition ++ ; mListTopOffset += getChildHeight ( firstChild ) ; if ( childCount > 1 ) { firstChild = getChildAt ( 0 ) ; } else { firstChild = null ; } } } if ( mFirstItemPosition != 0 && childCount > 1 ) { View lastChild = getChildAt ( childCount - 1 ) ; while ( lastChild != null && getChildTop ( lastChild ) + offset > getHeight ( ) ) { removeViewInLayout ( lastChild ) ; childCount -- ; mCachedItemViews . addLast ( lastChild ) ; mLastItemPosition -- ; if ( childCount > 1 ) { lastChild = getChildAt ( childCount - 1 ) ; } else { lastChild = null ; } } } }
removes view that are outside of the visible part of the list . will not remove all views .
