Swap two fragment simultaneously
<p>In my application i have one activity and i am adding two fragments at run time.I need to swap these two fragment simultaneously. Fragment 1 consist a button and i want when i click that button fragment 1 moves to right side of the screen and other fragment to the left side of the activity.</p>

<p>In the onClick method of the button i tried something like this</p>

<pre><code>    @Override
    public void onClick(View v) {
         FragmentTransaction ft = getFragmentManager().beginTransaction();
         Fragment newFragment = getFragmentManager().findFragmentById(R.id.pageA);
         ft.remove(newFragment);
         Fragment newFragmentB = getFragmentManager().findFragmentById(R.id.pageB);
         ft.remove(newFragmentB);
         ft.add(R.id.pageB, newFragment);
         ft.add(R.id.pageA, newFragmentB);
         ft.addToBackStack(null);
         ft.commit();
     }
</code></pre>

<p>But i am getting the following error </p>

<pre><code> java.lang.IllegalStateException: Can't change container ID of fragment PageA{40653da0   #0 id=0x7f060001}: was 2131099649 now 2131099650
</code></pre>

<p>I want something like this when i click the button on Page A then Position of Page A and PageB should swap with each other.</p>

<p><img src="http://i.stack.imgur.com/JHnDg.png" alt="UI of the fragment"></p>
