This wouldn't be the first time when the support library is somewhat inconsistent with native platform code.

Have you tried debugging into the library code?

The sources are available under android-sdk\extras\android\compatibility\v4\src.

-- K

20.04.2012 11:43, BoD ???????:
Thanks for answering.

However I already knew that, and it's not really the point of my question :)

--
BoD

On 04/20/2012 01:13 AM, lbendlin wrote:
Rotating the screen restarts the activity unless you explicitly tell the OS not to do that.

On Thursday, April 19, 2012 7:38:52 AM UTC-4, BoD wrote:

    Hi!

    I have an activity with a fragment that I hide in a transaction
    with a
    custom animation.
    This transaction is added to the back stack.
    If I don't rotate the screen this is working as expected (pressing
    'back' un-hides the fragment with the animation)

    1/ If I rotate the screen, the fragment is no longer hidden.  I
    discovered that if I call setRetainInstance(true) on the fragment
    however, this problem disappears.  But is this expected and/or
    documented somewhere?

    2/ But even if I do that, pressing 'back' shout un-hide the
    fragment,
    with the custom animation.  However:
      - Not using the support package, on a 3.2 Xoom, the fragment
    stays hidden.
      - Using the support package, the fragment does become visible
    again,
    but with no animation.
    Is this a (known) bug or did I miss something?

    Thanks a lot for your help!

    Here is the simple example demonstrating this (replace
    FragmentActivity
    by Activity and comment/uncomment to switch from using the support
    package or not):

    public class MainActivity extends FragmentActivity {
         @Override
         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.main);
             if (savedInstanceState == null) {
                 final TestFragment testFragment = new TestFragment();
                 testFragment.setRetainInstance(true);

                 final FragmentTransaction ftAdd =
    getSupportFragmentManager().beginTransaction();
                 // final FragmentTransaction ftAdd =
    getFragmentManager().beginTransaction();
                 ftAdd.add(R.id.container, testFragment);
                 ftAdd.addToBackStack(null);
                 ftAdd.commit();

                 final FragmentTransaction ftHide =
    getSupportFragmentManager().beginTransaction();
                 // final FragmentTransaction ftHide =
    getFragmentManager().beginTransaction();
                 //
    ftHide.setCustomAnimations(android.R.animator.fade_in,
    android.R.animator.fade_out, android.R.animator.fade_in,
    android.R.animator.fade_out);
                 ftHide.setCustomAnimations(android.R.anim.fade_in,
    android.R.anim.fade_out, android.R.anim.fade_in,
    android.R.anim.fade_out);
                 ftHide.hide(testFragment);
                 ftHide.addToBackStack(null);
                 ftHide.commit();
             }
         }

         public static class TestFragment extends Fragment {
             @Override
             public View onCreateView(LayoutInflater inflater, ViewGroup
    container, Bundle savedInstanceState) {
                 final TextView res = new TextView(getActivity());
                 res.setText("Fragment");
                 return res;
             }
         }
    }

-- BoD

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to