I'm using 3 Fragments
inside a Viewpager
, the problem is that I am loading big data in an Asynctask
and loaders. On devices like HTC one
, it works fine, however, on low-end devices, it takes a lot of time. This is mainly because when I implement the pagerAdapter
, I put the Fragments inside an ArrayList
, this force the fragments instantiate when the main activity is loaded. What I need is that it just "load" the first fragment (main) and when the user Swype
, load the other fragment. its any way to achieve this? this is my pageAdapater
public class PagerAdapter extends FragmentPagerAdapter {
private final ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
// private final ArrayList<String> titulos = new ArrayList<String>();
// private int NUM_PAGES =0;
public PagerAdapter(FragmentManager manager,int num_pages) {
super(manager);
// this.NUM_PAGES = num_pages;
}
public void addFragment(Fragment fragment,String title) {
mFragments.add(fragment);
notifyDataSetChanged();
}
@Override
public int getCount() {
//return NUM_PAGES;
return mFragments.size();
}
@Override
public Fragment getItem(int position) {
return mFragments.get(position);
}
}