ViewPager.setOffscreenPageLimit(0) doesn't work as expected

前端 未结 11 978
抹茶落季
抹茶落季 2020-11-22 13:02

The fragments I use in my ViewPager instance are quite resource intensive, so I\'d only like to load one at a time. When I try the following:

mV         


        
11条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 13:51

    this may be old thread but this seems to work for me. Override this function :

    @Override
    public void setMenuVisibility(boolean menuVisible) { 
        super.setMenuVisibility(menuVisible);
    
        if ( menuVisible ) {
            /**
             * Load your stuffs here.
             */
        } else  { 
            /**
             * Fragment not currently Visible.
             */
        } 
    }
    

    happy codings...

提交回复
热议问题