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. AI on the right track or is there a better way?
Thanks
Is there a way to load data from the web service asynchronously and populating the list when all data is retrieved?
Kick off an AsyncTask
to load the 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
You cannot invoke another AsyncTask
from doInBackground()
of an AsyncTask
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.