Reputation: 686
I have a view pager holding 3 fragments each fragment contains an async task that loads different urls for json data that is loaded into a custom listview in each fragment.
may problem is the view pager loads two fragments at a time, this delays the loding process, the progress dialogs from the next fragment are loaded in the current fragment. how can solve my problem.
Upvotes: 1
Views: 515
Reputation: 510
Dont load the three pages simulatneouly when the fragment is selected load the page.
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
if(this.isVisible()){
if (!isVisibleToUser) {
// TODO your async task .
}
}
super.setUserVisibleHint(isVisibleToUser);
}
Upvotes: 2
Reputation: 830
set setOffscreenPageLimit for View Pager
mPager.setOffscreenPageLimit(3);
where mPager is object of ViewPager.Hope this will help
Upvotes: 0