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

Author: Ankur

I am Enthusiastic about Learning new things and sharing my Knowledge. I like programming and have a pretty good background in Computer Science.

One thought on “Learn why to use a FrameLayout instead of Fragment in Layout XML”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: