This question has already been answered:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); layoutForFragment = (FrameLayout) findViewById(R.id.layout_for_fragment); fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.layout_for_fragment,cardStation); fragmentTransaction.commit(); } In the OnCreate method, I insert the fragment in FrameLayout. The problem is that when you rotate the screen or when you fly out with an error, the fragments overlap each other in the same place. How to solve a problem ?
.replaceinstead of.add- doomsilka