Create this method in the snippet:
public static MyFragment newInstance(int layout) { Bundle args = new Bundle(); args.putInt("layout", layout); MyFragment fragment = new MyFragment(); fragment.setArguments(args); return fragment; }
Next, write in onCreateView :
int layout = getArguments().getInt("layout", 0) View v = inflater.inflate(layout, container, false); return v;
call where you need MyFragment fragment = MyFragment.newInstance(my_layout);
Or, for example, to transfer some number to the fragment, which in the fragment, depending on the value ( switch(getArguments().getInt("number,0)) ), will load the required layout .