我正在使用一个FragmentPagerAdapter
来刷三个片段。它没有给我任何错误,但它总是提前加载下一个片段。我怎样才能阻止这种行为?
这是我的FragmentPagerAdapter
:
public class ViewPagerAdapter extends FragmentPagerAdapter {
private Context _context;
public ViewPagerAdapter(Context context, FragmentManager fm) {
super(fm);
_context = context;
}
@Override
public Fragment getItem(int position) {
Fragment f = new Fragment();
switch (position) {
case 0:
f = ReservationTab.newInstance(_context);
break;
case 1:
f = GalleryTab.newInstance(_context);
break;
case 2:
f = VideoTab.newInstance(_context);
break;
}
return f;
}
@Override
public int getCount() {
return 3;
}
}