Code example for FragmentStatePagerAdapter

Methods: destroyItem

0
        @Override 
        public void destroyItem(ViewGroup container, int position, Object object) { 
            final MyImageDetailFragment fragment = (MyImageDetailFragment) object; 
            // As the item gets destroyed we try and cancel any existing work. 
            fragment.cancelWork(); 
            super.destroyItem(container, position, object); 
        } 
         
    } 
}