android - ViewPager with FragmentStatePager -


i have viewpager coupled fragmentstatepager has around 8 fragments attached it. application designed wizard. user enters information on 1 page swpies next page , on. having problem collecting information , restoring information. when user swipes forward how can save information , when swpie functions gets called can read data object , populate screen ui ? have tried onsaveinstancestate hardly ever called. onresume called not. note using roboguice inject views fragment ui fields available after onviewcreated function. note each of 8 fragments implement following interface. in both these functions application level singelton either wriiten or read , access ui fields in fragment. cannot find out plug these functions ? suggestions of great use. have gussed setonpagechangelistener onpageselected event called before actual page visible user , can cause null pointer exception roboguice injections not ready.

public interface fragmentstate {     public void savefragementstate();     public void restorefragementstate(); } 

you should use viewpager.setoffscreenpagelimit(k) cache fragments of viewpager n-k n+k.

then can use onpageselected() safely:

    pager.setonpagechangelistener(new onpagechangelistener() {         public void onpagescrollstatechanged(int state) {          }          public void onpagescrolled(int position, float positionoffset,                 int positionoffsetpixels) {         }          public void onpageselected(int position) {             fragments.get(position).dothings();         }     }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -