Snippets are very useful if you want to split the screen. This way you can have different views on one screen. Another way to use fragments is to say that you have tabs for categorizing elements. Could have clothes, shoes as tabs. On each tab there will be a fragment for storing products. Tabs can either be held in activity or in a fragment. I find fragments a little faster than actions, but this is not really what you would really notice in most cases. Regardless of whether they were designed for speed or not, they still seem / feel a little faster.
The downside of using snippets is that certain callbacks, such as onBackPressed, only relate to activity. Fragments do not have access to this. I often find everything possible to minimize as much as possible. Also do not forget that Activities are not just views, they are also a screen. While the fragment is only a representation and does not have a screen. toolbars / actions, etc. also apply only to actions, but if you use a special toolbar, you can use it in a fragment, implementing onTouch (if not a button, but some object) or onClick (buttons), the method for them will give you what you need . So there really are some flaws, but at least some of them are almost bypassed.
I agree that the transition of the fragment is amazing and pushes the stack when working with buttons with feedback and onBackPressed. Trick.
I always use the switch in parenting activity, etc., to see which fragment should be in sight, I often update it with the interface transfer package, etc. Not sure if anyone else has found a more efficient way or not. But I really find it useful when switching views.
Yep fragments are the best brass for most things.
source share