2

我希望我的适配器在每次到达最后一页时添加另一个页面。这是我尝试使用的代码:

static int ITEMS = 2;

public static class MyAdapter extends FragmentStatePagerAdapter implements OnPageChangeListener{
    public MyAdapter(FragmentManager fragmentManager) 
    {
        super(fragmentManager);
    }

    @Override
    public int getCount() 
    {
        return ITEMS;
    }

    @Override
    public Fragment getItem(int position) 
    {
        if (position >= ITEMS-1)
        {
            ITEMS++;
            notifyDataSetChanged();
        }
        Fragment f = ReviewFragment.init(position); 
        return f;
    }
4

1 回答 1

0

我建议这样做:

public static class MyAdapter extends FragmentStatePagerAdapter implements OnPageChangeListener{
    public MyAdapter(FragmentManager fragmentManager) {
        super(fragmentManager);
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment f = ReviewFragment.init(position); 
        return f;
    }
}
于 2013-07-10T22:41:23.737 回答