Fragment completion

So, I began to tell how to open fragment . Here is my predicament. I have a list of elements (periodic table elements) that are next to my view . When you select an item, it displays information.

My problem is that I need to remove the view from (which we will call the fragment of parts) and delete from the stack so that I do not have a huge memory backup.

How to remove it from the stack when a new fragment is called to replace it?

+7
source share
2 answers

You can remove the fragment using the #remove() method of FragmentTransaction . This method also removes the view from the container to which it is bound.

However, from the documentation of the fragments:

Stopped: Fragment is not displayed. Either the host activity was stopped, or the fragment was removed from the operation, but added to the back stack. The stopped fragment is still alive (all information about the state and members is stored by the system). However, it is no longer visible to the user and will be killed if activity is killed.

If you add this fragment to the back stack, it will not be killed until activity is killed.

+3
source

You can try to opt out of backstack. This is when, when a fragment is deleted or replaced, it is not added to the stack, and it will need to be re-repeated (with data).

0
source

All Articles