Очень близко к тому, что вы хотите, мне нужно было добавить фрагмент (в конце) в ViewPager, и сделал это:
FragmentTransaction ft = fragmentManager.beginTransaction();
new_fragment = Fragment.instantiate(activity, class_name, args);
// The below code removes old fragment and adds the new one at the end.
ft.attach(new_fragment); // <- this adds the fragment at the end
ft.detach(old_fragment); // <- this removes old fragment
// This should be what you're looking for when adding to an Activity instead of a ViewPager
ft.replace(view_id, new_fragment); // <- this is supposed to replace the fragment attached to view_id
// Or if the replace does not work, this might work:
ft.detach(old_fragment);
ft.add(view_id, new_fragment);
// Not to be forgotten: ;)
ft.commit();
Приведенный выше код может нуждаться в некоторых корректировках, может быть, для эффективной работы требуется только вызов замены?
Если вызов замены не удался, вы все равно можете отсоединить все фрагменты и повторно присоединить их в нужном порядке.