Friday, 15 April 2011

android - ViewPager tries to load all fragments available even if i set offset limit to 1 which results in GC and blank screen? -



android - ViewPager tries to load all fragments available even if i set offset limit to 1 which results in GC and blank screen? -

i have implmented viewpager adapter of type fragmentstatepageradapter , have overrided getitem method returns fragment. have 1 fragment class input url show image differs , have layout heirarchy bit complex.

i have set viewpager offset limit 1 follows set logs check getitem , getsize of adapter getting called always.

viewpager.setoffscreenpagelimit(1);

as result when viewpager loading gc runs , blank screen comes time annoying.

following adapter code:

private class categoryviewpageradapter extends fragmentstatepageradapter { public categoryviewpageradapter(fragmentmanager fm) { super(fm); log.i("blank", "getitem phone call in fragment super call"); } @override public fragment getitem(int currentposition) { log.i("blank", "getitem phone call in fragment"); fullscreenfragment fragment = fullscreenfragment .newinstance(fragments.get(currentposition)); log.i("blank", "getitem phone call in fragment finished"); homecoming fragment; } @override public int getcount() { log.i("blank", "getitem phone call in fragment size"); homecoming fragments.size(); } }

how avoid blank screen when viewpager many items getting loaded? if open fragment stand lone loads fast complexity of hierarchy fine.

please help,

android android-fragments garbage-collection android-viewpager

No comments:

Post a Comment