How to handle AsyncTask's in ActionBarActivity Fragments when ViewPager is used?

前端 未结 4 1102
眼角桃花
眼角桃花 2020-11-28 13:11

I\'m using ActionBarActivity to create 5 tabs. I have used ViewPager to swipe between the 5 tabs using SectionsPagerAdapter which extends FragmentPagerAdapter. Each tab has

4条回答
  •  抹茶落季
    2020-11-28 13:32

    ViewPager creates views for fragments adjacent to your current page. This also gives you an opportunity to load any data required for the adjacent fragments. If you are using AsyncTasks to load data, using this feature will result in a better user experience. But if you need an event when a particular page is opened by the viewpager, LordRaydenMK's solution will work.

    See my post on the following thread for using AsyncTasks in a ViewPager:

    AsyncTask runs on each page of the ViewPager

提交回复
热议问题