Thursday, May 23, 2013

[android-developers] Re: Fragment state (and view) not restored when using ViewPager with nested fragments

Hi Streets Of Boston!

On Thursday, May 23, 2013 4:16:22 PM UTC+2, Streets Of Boston wrote:
> When using fragments inside a fragment, you should use the fragment's ChildFragmentManager and not the (activity's) main FragmentManager.

You are right. It's working when using child fragment manager, but the "backstack" inside the child fragment manager is not working. For instance, I'm replacing fragments based on user interaction, and when I call popBackStackImmediate(), the runtime throws NullPointerException: android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1419)

If I use popBackStack() instead of it's *Immediate sidekick, I get an IllegalStateException: Activity has been destroyed: android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1342)

That was the reason I wen't with "activity's fragment manager" in the beginning...

Any ideas what can be wrong? The "main" fragment in a viewpager inflates a layout with one "frame layout" inside. I'm addin child fragments to that frame layout, and calling addToBackStack(null) in the process.

Regards,
 Miha.





--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment