fragment - Android FragmentPagerAdapter showing up empty after cache clear -
i make fragmentpageradapter
there fragment has pager.
and pager show 3 fragments , works well.
but, after application cache clearing,
(it means... long time has passed application service backgrounded)
only pager showing , 3 fragments have empty layout (white space).
as result checking log, caught problem lines...
after clearing cache, sectionspageradapter() constructure called then
getitem() method never called.
please me
public class reviewfragment extends sherlockfragment { private sectionspageradapter msectionspageradapter; private viewpager mviewpager; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.review_fragment, container, false); return rootview; } @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); if (savedinstancestate == null) { msectionspageradapter = new sectionspageradapter(getactivity().getsupportfragmentmanager()); mviewpager = (viewpager) getactivity().findviewbyid(r.id.pager); mviewpager.setadapter(msectionspageradapter); } } public class sectionspageradapter extends fragmentpageradapter { public sectionspageradapter(fragmentmanager fm) { super(fm); } @override public fragment getitem(int position) { if (position == 0) { return new bfragment(); } else { return new cfragment(); } } @override public int getcount() { return 2; } @override public charsequence getpagetitle(int position) { switch (position) { case 0: return "1"; case 1: return "2"; } return null; } }
Comments
Post a Comment