It depends on how different the data is going to be. If every fragment will only have an ImageView you could reuse the same fragment like what you are doing. You just need to check the position in your getItem method and send different data to that instance of the fragment through the bundle. Then inside your DummySectionFragment you can check the data you passed it, even if its just the position, and add a different image depending on the data/position.
If the content on each fragment is going to be different, then you should create a different fragment for each section. So instead of having just a DummySectionFragment you would have a different fragment per section and give each one a new layout depending on your needs.
Unless you will only use the position to modify the data in each fragment, your getItem should look like this:
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
Bundle args = new Bundle();
switch(position){
case 0:
fragment = new DummySectionFragment();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
case 1:
fragment = new DummySectionFragment();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
case 2:
fragment = new DummySectionFragment();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
}
return fragment;
}
The only difference is that if you go with the second approach each case you will instantiate a different fragment and not the same one.
If you only want to change the image based on the position of the fragment you can keep your code the same and just check the position inside your DummySectionFragment like this:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main_dummy,
container, false);
int position = Integer.toString(getArguments().getInt(
ARG_SECTION_NUMBER))
if(position == 1){
//Your on the first tab..
}
return rootView;
}
Good Luck!