可能重复:
ViewPager 作为循环队列/包装
我的代码中有三个片段类。FirstActivity,SecondActivity,ThirdActivity 我想刷这三个活动..这三个是从 Fragment 类扩展的
public class ViewPagerFragmentActivity extends FragmentActivity {
private PagerAdapter mPagerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
super.setContentView(R.layout.viewpager_layout);
initialisePaging();
}
/**
* Initialize the fragments to be paged
*/
List<Fragment> fragments = new Vector<Fragment>();
ViewPager pager;
private void initialisePaging() {
fragments.add(Fragment.instantiate(this, FirstActivity.class.getName()));
fragments.add(Fragment.instantiate(this, SecondActivity.class.getName()));
fragments.add(Fragment.instantiate(this, ThirdActivity.class.getName()));
this.mPagerAdapter = new MyPagerAdapter(super.getSupportFragmentManager(), fragments);
pager = (ViewPager) super.findViewById(R.id.viewpager);
pager.setAdapter(this.mPagerAdapter);
}
}
这是我的 FragmentPageAdapter 类
public class MyPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> fragments;
public MyPagerAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
}
@Override
public Fragment getItem(int position) {
System.out.println("position"+position);
return this.fragments.get(position);
}
@Override
public int getCount() {
return this.fragments.size();
}
}
我的代码以这种方式工作, A<->B<->c
但我的要求是像这样运行C<->A<->B<->C<-A->
,在圆形片段中是可滑动的......