title: destroy fragment completely Android
body: <p>i have an activity and i want to change fragments depending on the orientation of the device. so here is my code:   </p>
  
  <pre><code>FragmentTransaction ft = getFragmentManager().beginTransaction();
  
   if(getFragmentManager().findFragmentById(R.id.calendrier_calendrierhebdomadaire) != null){
          Fragment fragment = getFragmentManager().findFragmentById(R.id.calendrier_calendrierhebdomadaire);
          ft.remove(fragment);
      }
  
  ft = getFragmentManager().beginTransaction();
  
  if(getResources().getConfiguration().orientation == 1){       
      ft.add(R.id.calendrier_planifications, new Planifications());
  }
  
  else if(getResources().getConfiguration().orientation == 2){
  
      ft.add(R.id.calendrier_planifications, new Planifications());
      ft.add(R.id.calendrier_calendrierhebdomadaire, new Test());  
  
  }
  
  ft.commit();
  </code></pre>
  
  <p>I am using two different layout files : layout/calendrier.xml containing two LinearLayouts, layout-port/calendrier.xml containing 1 LinearLayout</p>
  
  <p>the problem is when i start my application in the landscape mode (orientation == 2) and switch it to the portrait mode (orientation == 1), i still have methods of my fragment Test executed.</p>
  
  <p>How to completely remove the Test Fragment ?</p>