Learn why to use a FrameLayout instead of Fragment in Layout XML

If you read the earlier Article in which I talked about the BackStack then you might have noticed the following code in the MainActivity layout file.


I mentioned that using a FrameLayout instead of a Fragment element is helpful if we want to replace the current fragment with another one.

In our scenario when a user will click on an Employee then the Employee detail will appear, which means the detail fragment will be replaced with a new instance every time.

You can refer to the Source Code here