public class MyPagerAdapter extends FragmentStatePagerAdapter {
private final String[] TITLES = { "Categories", "Home", "Top Paid" };
public MyPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public CharSequence getPageTitle(int position) {
return TITLES[position];
}
@Override
public int getCount() {
return TITLES.length;
}
@Override
public Fragment getItem(int index) {
switch (index) {
case 0:
// Top Rated fragment activity
return new TopRatedFragment();
case 1:
// Games fragment activity
return new GamesFragment();
case 2:
// Movies fragment activity
return new NoteActivity();
}
return null;
}
我在getItem()中有3个片段如你所见,它的构造函数是Fragment类型,但是我需要其中一个是listfragment,构造函数不接受,我坚持这个问题,你能不能帮我一下线索?感谢