android - Fragment doesn't refresh content after returning from back stack -
i have zoofragment
contains viewpager
. viewpager
has 3 children: lionfragment
, leopardfragment
, , tigerfragment
, each of these children can request transaction call new zoofragment
.
when zoofragment
called zooa
(with arguments) initialized, 3 children in viewpager
display content. child fragment, user touch call new zoofragment
called zoob
(with different arguments, of course).
based on transaction action child fragment zoofragment
:
1.if use transaction.replace()
, zoob
blank, 3 children in zoob
display no content, empty. @ zoob
, pressing hardkey back
navigation, zooa
becomes empty.
2.if use transaction.add()
, zoob
won't blank, following back
button press, zooa
gets empty.
in zoofragment
class, loading data in oncreateview()
, reason why child fragments in viewpager
empty?
please not replace fragments in viewpager, show (using transaction) in other contained in same layout of viewpager , container should framelayout. device mechanism know when , fragment comes view. request fresh data utility responds update fragment. not think ondestroyed called in case of fragments in viewpager. fragments in viewpager fixed, should there contents not go till application manager wants destroy it.instead of trying replace fragments in adapter, try give different set of fragments , notifydataset changed, or take advantage of framelayout show fragment on view pager tab's current fragment.
there solution works:
swipe gesture applied @ fragment level along viewpager it's default swipe disabled
Comments
Post a Comment