Android Async task in viewpager -
i using fragmentstatepageradapter set viewpager content. in getitem() method of adapter, invoke fragment. want display product images , names dynamically server on each view pager fragment. calling async task in oncreateview() of fragment. async task adjacent products invoked. want know best way ?
should perform async task ahead , set adapter of view pager? if so, have 1000s of products, take huge time set adapter.
or should perform async task after every page has loaded? here, every time come page, keeps loading data server. want data loaded first time visit page, on next swipe, should display instead of fetchng server again.
i infinite view pager adapter, how possible ?
many in advance :)
... want data loaded first time visit page, on next swipe, should display instead of fetchng server again.
move asynctask
call oncreateview
setuservisiblehint
: executed when fragment visible user:
@override public void setuservisiblehint(boolean isvisibletouser) { super.setuservisiblehint(isvisibletouser); if (isvisibletouser) { // launch asynctask here, if task has not been executed yet if(atask.getstatus().equals(asynctask.status.pending)) { atask.execute(); } } }
... infinite view pager adapter, how possible ?
this has been answered, i.e.:
Comments
Post a Comment