Obsolete
Status Update
Comments
mi...@gmail.com <mi...@gmail.com> #2
Note: I currently do not have a workaround for this issue.
hi...@gmail.com <hi...@gmail.com> #3
Same do I. Anybody help?
ia...@gmail.com <ia...@gmail.com> #4
I've had symptoms very similar to the ones described here.
In my case I have a tab bar, the content of a tab is a Fragment and that contains a ViewPager to swipe left and right between N other Fragment instances. After switching tab to another tab and coming back (this causes detaching and attaching of the tab Fragments from/to the Activity) the Fragments in the ViewPager would initially not show, after some swipes they start showing.
I solved this by using getChildFragmentManager() in the parent Fragment (the one hosting the tab content) to create the FragmentManager for the FragmentStatePagerAdapter constructor (which then creates the individual Fragment instances for each ViewPager swipe). So Fragments within Fragments need to use getChildFragmentManager() instead of the global one retrieved via getSupportFramentManager()/
In my case I have a tab bar, the content of a tab is a Fragment and that contains a ViewPager to swipe left and right between N other Fragment instances. After switching tab to another tab and coming back (this causes detaching and attaching of the tab Fragments from/to the Activity) the Fragments in the ViewPager would initially not show, after some swipes they start showing.
I solved this by using getChildFragmentManager() in the parent Fragment (the one hosting the tab content) to create the FragmentManager for the FragmentStatePagerAdapter constructor (which then creates the individual Fragment instances for each ViewPager swipe). So Fragments within Fragments need to use getChildFragmentManager() instead of the global one retrieved via getSupportFramentManager()/
da...@gmail.com <da...@gmail.com> #5
I can confirm me that changing to getChildFragmentManager solved the problem for me.
vm...@gmail.com <vm...@gmail.com> #6
Thank you so much, getChildFragmentManager() solved my problem too.
sa...@gmail.com <sa...@gmail.com> #7
I can alos confirm that changing to getChildFragmentManager solved the problem for me. Thank you very much.
[Deleted User] <[Deleted User]> #8
I can alos confirm that changing to getChildFragmentManager solved the problem for me. Thank you very much.
[Deleted User] <[Deleted User]> #9
Upvote.
th...@gmail.com <th...@gmail.com> #10
Thank you very much!
This problem wasted my time
This problem wasted my time
fr...@gmail.com <fr...@gmail.com> #11
Good job! Thanks
li...@gmail.com <li...@gmail.com> #12
ThankYou!
getChildFragmentManager solved my issues
getChildFragmentManager solved my issues
le...@gmail.com <le...@gmail.com> #13
Thank you , getChildFragmentManager() solved my problem too.
jh...@gmail.com <jh...@gmail.com> #14
@iacobcatalin@gmail.com
i came up with the same problems.
When i tried your method. Everything went well!!!
Thanks you very much!
When i use the method "getFragmentManager()", almost everything goes well except when onPause and onResume. what the f*ck the api set. It should have throw an Exception if i use "getFragmentManager" where "getChildFragmentManager" should be.
i came up with the same problems.
When i tried your method. Everything went well!!!
Thanks you very much!
When i use the method "getFragmentManager()", almost everything goes well except when onPause and onResume. what the f*ck the api set. It should have throw an Exception if i use "getFragmentManager" where "getChildFragmentManager" should be.
en...@google.com <en...@google.com>
lo...@gmail.com <lo...@gmail.com> #15
Thank you , getChildFragmentManager() it works !!!!!!!
bo...@gmail.com <bo...@gmail.com> #16
getChildFragmentManager() works pretty well..
tf...@gmail.com <tf...@gmail.com> #17
Thanks, getChildFragmentManager does the trick.
th...@gmail.com <th...@gmail.com> #18
getChildFragmentManger really dost the f**king trick. Thumb Up!
jo...@gmail.com <jo...@gmail.com> #19
Arghhhh, getChildFragmentManger is all that was needed, Thank you
oz...@gmail.com <oz...@gmail.com> #20
getChildFragment solved the issue thank you!!
km...@gmail.com <km...@gmail.com> #21
Thank you man.getChildFragment solved the issue.
de...@gmail.com <de...@gmail.com> #22
Thanks a lot!! for me as well, getChildFragmentManager() solved the issue.
ca...@gmail.com <ca...@gmail.com> #23
confirm that getChildFragmentManager is needed!!!!!
k....@gmail.com <k....@gmail.com> #24
If I init my adapter in Activity, how can I access to getChildFragmentManager?
[Deleted User] <[Deleted User]> #26
Thanks a million. getChildFragmentManager() solved my problem.
ma...@gmail.com <ma...@gmail.com> #27
Thanks a million. getChildFragmentManager() solved my problem.
Description
UI Setup:
1 Activity:
Main Activity - hosts fragments. Fragments 1 & 2 (defined below) are swapped via FragmentTransaction.
2 Fragments
1.) ListFragment - Contains a typical listview. Referenced as "Fragment 1"
2.) PagerFragment - Extends upport.v4.app.Fragment. Referenced as "Fragment 2". Hosts a support.v4.view.ViewPager and a support.v4.app.FragmentStatePagerAdapter.
3.) ListFragment - Contains a typical listview. Referenced as "Fragment 3.n" THIS is the view that is controlled by the ViewPager.
Heirarchy:
- Activity
-> ListFragment
-> PagerFragment (instance of Fragment)
- > ListFragment ( n instances of ListFragment )
Brief synopsis of issue:
When traversing backstack from Fragment 1 to Fragment 2, the contents of Fragment 3.n do not repopulate.
Replication:
1.) Create activity to load Fragment ***2*** upon startup. Note correct loading of paged fragment (Fragment 3.m)'s list fragment.
2.) Via action, instruct Activity to replace Fragment 1 with Fragment 2. Note correct loading of Fragment 2's listview elements (addToBackStack() is subsequently called).
3.) Press back button. Note that the ViewPager is loaded with the correct state (e.g. the PageTitle depicts the last viewed fragment). PROBLEM OCCURS HERE.....Note *the absence of* the Fragment 3.n screen. If you swipe to the right *once*, the ViewPager fragment for that *also does not* show on screen. Swipe right once more and the view pager *does* show the fragment on screen. Swipe left....still nothing. Swipe left again (back to original fragment) and the Fragment 3.n contents are *now being shown*.
Observations:
1.) The lifecycle methods on the ViewPager's parent fragment (Fragment 2) *are* being called (onViewStateRestored() and onResume() ).
2.) FragmentStatePagerAdapter's getItem() not being called for Fragment 3.0 and 3.1 upon back navigation. Once Fragment 3.2 is navigated to (via first swipe right in above procedure), getItem() is called to retrieve Fragment 3.2.
3.) Swipe right once more and getItem() called for Fragment 3.3 (present on screen fragment is 3.2)
4.) Swipe left from Fragment 3.2 and a call to getItem() is made for Fragment 3.0. Swipe left to Fragment 3.0 and fragment contents are now onscreen.
5.) Regardless of setting viewpager's setSaveEnabled(true/false), onSaveInstanceState() is not called.
6.) Error occurs whether or not the listadapter driving Fragment 3.n's list views utilized view recycling or not.
7.) ViewPager's host fragment calls onCreateView() and executes the exact same body of code during app startup as well as during back navigation.
8.) Explicit calls to viewpager's host fragment's view (obtained via getView() on host fragment)'s refreshDrawableState() and requestLayout() yield no change.
Potential issue:
getItem() not being called when view pager's host fragment recreates the fragment upon fragment resume.