locked
Fragment in a Fragment after rotate do not add into the page. RRS feed

  • Question

  • User31956 posted

    Precondition 1. All fragment has RetainInstance = true 2. Use Component Android Support Library v4 3. Layout of Fragment has ViewPager, each page has a fragment

    Recently, our project perform the upgrade to target Lollipop. However, the part that has the above conditions do not work after rotate. I created a sample project that could simulate this issue.

    Steps to reproduce: 1. Run the application. 2. The application allows you to slide left and right. Sliding from left and right will shows another fragment with 2 different values and color. 3. Rotate the device at any time, the fragment within the pager do not appears.

    I noticed the following is printed with bold.

    [] PageFragment OnSaveInstanceState: pageradaptertest.SlidingMainActivity@413bc810-PageFragment{413ffcb8 #1 id=0x7f050009} 1 start [] PageFragment OnSaveInstanceState: pageradaptertest.SlidingMainActivity@413bc810-PageFragment{413ffcb8 #1 id=0x7f050009} 1 end * [PhoneWindow] Previously focused view reported id 2131034131 during save, but can't be found during restore.* [] Content fragment: MainFragment{413ca730 #0 id=0x7f050005} start [] Content fragment: MainFragment{413ca730 #0 id=0x7f0500````05} end

    This is working earlier in the previous version before the new component Android Support Library v4 is added. The reason it is added is a lot of warning is shown after the build, and suggested us to update it.

    Attached a sample project to simulate it.

    Thursday, February 12, 2015 10:35 AM

All replies

  • User31956 posted

    Also, I attach 2 copy that works.

    1. Retain instance = false
    2. Use the older support library.

    Does it mean that the newer support library cannot be used?

    Friday, February 13, 2015 6:36 AM
  • User31956 posted

    No feed back?

    Saturday, February 21, 2015 3:37 PM