I am using a android.support.v4.view.ViewPager and wish to page through its views quickly.
Currently, each ListFragment view within my ViewPager needs to access a web service before it can display its list. I do this by retrieving data and calling setListAdapter within the Fragments onCreate method. This causes the ViewPager to “hang” when swiping between it’s views due to the delay retrieving data from the web service.
Is there a way to load data from the web service asynchronously and populating the list when all data is retrieved? Ideally, I want to page through the ViewPager quickly and display a loading indicator whilst each child ListFragment loads its required data.
Note: I have tried using an ASyncTask to call the web service and set the list adapter but have had issues calling an ASyncTask from within an ASyncTask. A I on the right track or is there a better way?
Thanks
Kick off an
AsyncTaskto load the data.You cannot invoke another
AsyncTaskfromdoInBackground()of anAsyncTask.