Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This appears to be a bug reported at</p> <p><a href="https://code.google.com/p/android/issues/detail?id=42601">https://code.google.com/p/android/issues/detail?id=42601</a></p> <p>The variable </p> <p>FragmentManagerImpl mChildFragmentManager;</p> <p>In Fragment.java is not set to null on detach. So the next time the fragment is loaded, the variable still points to the last parent.</p> <p>As discussed on that thread, a workaround is to reinstantiate the Fragment.</p> <p>In my case, I was switching between fragments in an ActionBar tab. The troubled Fragment has nested Fragments and was crashing the app when coming back to the file loader Fragment. So this is the work-around code:</p> <pre><code>class MainTabsListener implements ActionBar.TabListener { public Fragment fragment; public int TabPosition; public MainTabsListener(Fragment fragment, int tab_position) { this.fragment = fragment; TabPosition = tab_position; } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { CurrentFragment = fragment; CurrentTabSelectedPos = TabPosition; /** * This is a work-around for Issue 42601 * https://code.google.com/p/android/issues/detail?id=42601 * * The method getChildFragmentManager() does not clear up * when the Fragment is detached. */ if( fragment instanceof FileLoaderFragment ){ fragment = reinstatiateFileLoaderFragment(); } ft.replace(R.id.fragment_container, fragment); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { ft.remove(fragment); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload