0

I have a fragment A and a fragment B.

In fragment A i do a inflation of a some views to inside a container. Then i change to a fragment B, and when i turn to fragment A, the views that inflate are gone and i lost the data inside this views.

Anyone know what is the problem? Thanks by your time and help

enter image description here

Ricardo Filipe
  • 435
  • 4
  • 8
  • 24

1 Answers1

0

Check out the life cycle of a Fragment: http://developer.android.com/guide/components/fragments.html#Lifecycle

you can use the methods onSaveInstanceState() to save data and onCreateView() to reload important data.

you should create all your UI data inside the onCreateView() instead of the Fragment constructor and then it will be called each time you re-create the View.

Rotem
  • 1,472
  • 2
  • 11
  • 18