当我关闭(onPause
)我的应用程序并重新打开它时onResume
,
不会调用ViewPager
扩展FragmentPagerAdapter
覆盖方法的适配器。getItem()
我该如何调用它?这是我的 viewPager 适配器:
public class MyPagerAdapter extends FragmentPagerAdapter {
private final String TAG = "MyPagerAdapter";
private int MAX_COUNT = 100;
fragment1 myFragment;
public MyPagerAdapter(FragmentManager fm) {
super(fm);
Log.d(TAG, "Created adapter for pager");
}
public void setCount(int count) {
MAX_COUNT = count;
}
@Override
public Fragment getItem(int position) {
Log.d(TAG, "getting item at " + position);
myFragment = new fragment1();
myFragment.position = position;
Log.d("Fragment", "Position: " + position);
return myFragment;
}
@Override
public int getCount() {
return MAX_COUNT;
}
}