Code example for ListView

Methods: getChildAtgetHeaderViewsCount, getContext, getFirstVisiblePosition

0
     */ 
    @Override 
    public View onCreateFloatView(int position) {
        // Guaranteed that this will not be null? I think so. Nope, got 
        // a NullPointerException once... 
        View v = mListView.getChildAt(position + mListView.getHeaderViewsCount() - mListView.getFirstVisiblePosition());
 
        if (v == null) {
            return null; 
        } 
 
        v.setPressed(false);
 
        // Create a copy of the drawing cache so that it does not get 
        // recycled by the framework when the list tries to clean up memory 
        //v.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); 
        v.setDrawingCacheEnabled(true);
        mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
        v.setDrawingCacheEnabled(false);
 
        if (mImageView == null) {
            mImageView = new ImageView(mListView.getContext());
        } 
        mImageView.setBackgroundColor(mFloatBGColor);
        mImageView.setPadding(0, 0, 0, 0);
        mImageView.setImageBitmap(mFloatBitmap);