Android replaces a fragment or starts a new activity with a fragment

I'm still not sure about the best design methods using fragments. I looked at the dev docs:

http://developer.android.com/guide/components/fragments.html

There seem to be two ways to make a new screen in at least one window. Let's say I have a button inside one fragment, and I want it to show a new view when clicked. Should I use the original action and replace it with FragmentTransaction, or should I start the original launch with the goal of a new action that displays this fragment. I am sure both can work. I'm more interested in design practice. Or should I use a dialog snippet?

If that matters, the second fragment must at any time pass the information to the original fragment.

+4
source share
1 answer

If all you have to do is return some data to the fragment, I would probably use Dialog.

However, to switch fragments, it is much better to use FragmentTransaction to change fragments, so you do not need new activity (one of the main possibilities for using fragments).

0
source

Source: https://habr.com/ru/post/1486127/


All Articles