在程序中有20个FragmentActivity,它们都像游戏屏幕一样以不同的结构呈现。我想把它们都放在ViewPager中。我查了半天资料就获得了以下方法:
public static class MyAdapter extends FragmentPagerAdapter { @Override public Fragment getItem(int position) { switch(position){ case 0: return new Fragment1(); case 1: return new Fragment2(); ......................... another 20 case statements here ......................... case 20: return new Fragment21(); } } }
肯定还有别的方法实现。大家有什么好的建议吗?
慕后森
相关分类