I have a ZooFragment
that contains a ViewPager
. This ViewPager
has three children: LionFragment
, LeopardFragment
and TigerFragment
, each of these children can request a transaction to call a new ZooFragment
.
When a ZooFragment
called zooA
(with arguments) is initialized, all three children in the ViewPager
display the contents. From any child fragment, the user call will invoke a new ZooFragment
called zooB
(with different arguments, of course).
Based on transaction action from child fragment to ZooFragment
:
1.If I use transaction.replace()
, zooB
will be empty, all three children in zooB
will not display the contents, empty. In zooB
pressing the Back
key from the navigation, zooA
becomes empty.
2.If I use transaction.add()
, zooB
will not be empty, then after clicking the Back
button, zooA
will be empty.
In the ZooFragment
class ZooFragment
I load data into onCreateView()
, so why do all child fragments in the ViewPager
become empty?
source share