I created a bug report for this a couple of days ago, but it doesn't
seem to have received any attention:

http://code.google.com/p/android/issues/detail?id=14796

To reproduce the problem, add the following callback override to the
TitlesFragment class in FragmentLayout.java under the ApiDemos project
in samples for Honeycomb Preview:

        @Override
        public void onInflate(AttributeSet attrs, Bundle
savedInstanceState) {
                Bundle args = new Bundle();
                for(int i=0; i<attrs.getAttributeCount(); i++) {
                Log.v("14796", "    " + attrs.getAttributeName(i) +
                                " = " + attrs.getAttributeValue(i));
                args.putString(attrs.getAttributeName(i),
                               attrs.getAttributeValue(i));
                }
                this.setArguments(args);
                super.onInflate(attrs, savedInstanceState);
        }

This is doing what the the documentation says you should do. That is,
take attributes passed in and save them in the arguments bundle on the
fragment instance. However, if you launch this activity then rotate
the screen, the activity crashes with an IllegalStateException. And it
does that because onInflate() gets called way too late when Android is
rebuilding the activity and its fragments. If the layout for the other
orientation is different that the previous layout, you'll have no way
to use any of the attributes in onCreateView() for the fragment,
because onInflate() isn't being called until later.

I haven't come up with a workaround either. The fragment can't even
see the activity until onAttach(), and you can't set the arguments
bundle once onAttach() has been called.

The sample activities so far haven't tried to utilize this feature, so
perhaps it won't affect most people. But for those who need or want
it, it doesn't seem to work.

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to