Very close to what you want, I needed to add a fragment (at the end) in the ViewPager and do this:
FragmentTransaction ft = fragmentManager.beginTransaction(); new_fragment = Fragment.instantiate(activity, class_name, args);
In the above code, some adjustments may be required, maybe you only need to efficiently execute a replacement call?
If the replacement call failed, you can detach all the fragments and reconnect them in the desired order.
source share