Code example for SparseArray

Methods: deletegetput

0
     
    class RecycleBin { 
        private final SparseArray<View> mScrapHeap = new SparseArray<View>();
 
        public void put(int position, View v) {
            mScrapHeap.put(position, v);
        } 
         
        View get(int position) {
            // System.out.print("Looking for " + position); 
            View result = mScrapHeap.get(position);
            if (result != null) {
                // System.out.println(" HIT"); 
                mScrapHeap.delete(position);
            } else { 
                // System.out.println(" MISS"); 
            } 
            return result;
        }