I think there is another issue, related to the one discussed in this
thread:

http://groups.google.com/group/android-developers/browse_thread/thread/6cfac9e17dd7afe9/0ff2c762526e1f22?lnk=gst&q=fragment#

My application, as is typical, does something like this:

    public void onCreate(Bundle state) {
        super.onCreate(state);
        setContentView(R.layout.main);

R.layout.main contains a Fragment.

If I get my app going and get a few fragments on the back stack, and
then switch from portrait to landscape (or vice-versa), it crashes
with the dreaded "IllegalState... did not create a view".

The reason is that when Activity.onCreate is called any attached
fragments are in the state INITIALIZING and are moved to CREATED.
Unless they are mFromLayout, their onCreateView is not called.  The
most the original fragment -- the one from the layout -- has been
replaced by one that is not from the layout.  Boom.

Calling setContentView from Activity.onStart() makes the problem go
away.  So does setting mFromLayout true, in the fragment constructor.

I'm not sure I'd call this a bug but it sure is surprising.  I'm not
sure I understand the correct way to handle it, either.  Setting
mFromLayout requires bare-faced hackery but it sort of seems like what
I want: I want replacements for the original, in-layout fragment to
behave just like it did.

Moving onCreate code to onStart is, maybe, ok, but it requires doing a
lot of initialization that probably ought to be one-time, every time
the app becomes visible.

Suggestions?

-blake

-- 
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