Here you go -
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
ImageListFragment fragment2 = new ImageListFragment();
Bundle bundle2 = new Bundle();
bundle2.putInt("eventId", 100);
fragment2.setArguments(bundle2);
for(int i = 0; i < count; i++){
ImageListFragment fragment = new ImageListFragment();
Bundle bundle = new Bundle();
bundle.putInt("eventId", eventIds.get(i));
bundle.putInt("id", id);
fragment.setArguments(bundle);
adapter.addFragment(fragment, eventNames.get(i));
}
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(position);
viewPager.setOffscreenPageLimit(1);
So basically you need to run a loop and create new fragment everytime and add it to your adapter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…