A
A
Alexander Kolmachikhin2019-01-08 07:57:37
Java
Alexander Kolmachikhin, 2019-01-08 07:57:37

Which is better: include or fragment?

I have been writing my application for some time now. After creating the BottomNavigationView, I did not know how to switch between screens, but I immediately got the idea - just give one element View.VISIBLE and another View.GONE.
After a while, I learned about fragments. A lot has already been written through the task of visibility, and I decided not to waste energy on it. But these fragments did not give me rest, why everyone uses them, but no one uses my method?
To the essence of the question, which is better: include, through setting visibility, or fragment, through its display methods? And why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-01-08
@Alexander_Kolmachikhin

Fragments, of course.
I can tell a story. A few years ago I saw your approach in the application. There, as a result, some sections opened in a second, because it was necessary to de-layout the entire hierarchy, and it became very fat. Then memory problems started, and at some point reports about a stack overflow in layout/measure began to come to the crashlist due to the depth of the hierarchy. Rewriting into fragments was very difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question