usuń fragment fragmentu

Po prostu uczę się dzisiaj fragmentów. Naciskam przycisk i dodaje / usuwa fragment. Jeśli jednak spróbuję usunąć fragment, każdy fragment oprócz tego, który chcę usunąć, zostanie usunięty, dlaczego? Pierwsze naciśnięcie poprawnie dodaje fragment.

Button2 fragment:

 Button button = (Button) view.findViewById(R.id.button2);
        button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {

              ButtonFragment fragment = new ButtonFragment();
              if (fragment != null && fragment.isVisible()) {



                  FragmentManager fragmentManager = getFragmentManager();

                  FragmentTransaction transaction =  fragmentManager.beginTransaction(); 
                  transaction.remove(fragment).commit();

              }
              else if(!fragment.isVisible())
              {
                  FragmentManager fragmentManager = getFragmentManager();

                  FragmentTransaction transaction =  fragmentManager.beginTransaction(); 
                  transaction.add(R.id.fragment_container, fragment ).commit();
  }       

          }
        });
        return view;
      }
}

Mam dwa takie fragmenty w xml: Po kliknięciu przycisku chcę, aby fragment nie zdefiniowany w xml został dodany i tak jest. Jednak następnym razem, gdy nacisnę przycisk, który powinien usunąć ten fragment. Wszystko jest usuwane poza tym fragmentem.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:background="#123456"
    android:id="@+id/fragment_container"  >


    <fragment
        android:id="@+id/TimeFragment"
        android:layout_width="0dp"
        android:layout_weight="2"
        android:layout_height="match_parent"
        class="com.example.myfragment.TimeFragment" >
        <!-- Preview: layout=@layout/details -->
    </fragment>



    <fragment
        android:id="@+id/Button2Fragment"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="match_parent"
        class="com.example.myfragment.Button2Fragment" >
        <!-- Preview: layout=@layout/details -->
    </fragment>

</LinearLayout> 

questionAnswers(1)

yourAnswerToTheQuestion