Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I might not fully have understood your code but I suspect this bit in your MainActivity's onCreate:</p> <pre><code> frAdapter = new FragmentAdapter(getSupportFragmentManager()); vPager = (ViewPager)findViewById(R.id.pager); vPager.setAdapter(frAdapter); vPager.setCurrentItem(1); vPager.setOnPageChangeListener(this); vPager.setOffscreenPageLimit(3); </code></pre> <p>Think you should save currentItem in onSaveInstance and retrive it:</p> <pre><code> vPager.setCurrentItem(value_before_orientation_change); </code></pre> <p>Not 100% sure if the vPager actually overwrites your fragment as I suspect though.</p> <p>Edit:</p> <p>Even more likely, in your CenterPanelFragment.java in onActivityCreated you commit the catalog: </p> <pre><code> fragmentTransaction.replace(R.id.fragment_container, fragmentCatalog); fragmentTransaction.addToBackStack("FragmentCatalog"); fragmentTransaction.commit(); </code></pre> <p>Maybe something as simple as setRetainInstance(true) in onCreate at CenterPanelFragment could resolve this problem.</p> <p>I am pretty confident that the orientation change relaunches your CenterPanelFragment, causing a new call to onActivityCreated.</p> <p>Think you could try in your <strong>FragmentCatalog</strong>:</p> <p>And change this line:</p> <pre><code>fragmentTransaction.replace(R.id.fragment_container, fcAllStone); </code></pre> <p>To:</p> <pre><code>fragmentTransaction.replace(R.id.fragment_container, fcAllStone, "fragment_stone"); </code></pre> <p>Now in <strong>CentralPanelFragment</strong>:</p> <pre><code> if (savedInstanceState != null) { Log.d(MainActivity.tag, "CenterPanelFragment not null"); fragmentCatalog = (FragmentCatalog)getFragmentManager().getFragment(savedInstanceState, FragmentCatalog.class.getName()); // see if stone is open if (savedInstanceState != null) { FragmentCatalogStone fragmentStone = (FragmentCatalogStone) getFragmentManager() .findFragmentByTag("fragment_stone"); if (FragmentCatalogStone != null) { /* * maybe recommit it, dont actually think anything is needed * since moving the below code inside the else statement * prevents it from overwriting the FragmentCatalogStone */ } } else { Log.d(MainActivity.tag, "CenterPanelFragment null"); fragmentCatalog = new FragmentCatalog(); android.support.v4.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.fragment_container, fragmentCatalog); fragmentTransaction.addToBackStack("FragmentCatalog"); fragmentTransaction.commit(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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