edit (2nd answer):
I played with the code and I'm still not sure WHY this is happening, there is definitely something wrong with the fragment manager when it exchanges fragments (replace (resId, fragment))
In my onCreateView snippet there was this code:
View view = inflater.inflate(R.layout.post_fragment, null, false); if (item == null) return view; return BuildView(view);
post_fragment is an empty canvas with 1 ScrollView, 1 LinearLayout inside it and some other ViewGroups inside it. It needs to load an empty canvas on the 1st load (the element is null), and in the second - through user input, it will receive the actual data for display.
for some reason, as far as I know, as shown in logcat, FragmentManagerImpl.moveToState caused a ScrollView.AddChild error.
Now I changed my onCreateView snippets to:
if (item == null) return inflater.inflate(R.layout.empty, null, false); View view = inflater.inflate(R.layout.post_fragment, null, false); return BuildView(view);
so the "empty" canvas is FrameLayout, on which there is nothing, and now everything works happily. I'm sure this sounds like an odd mistake in the real frame structure, but it works around it.
1st answer:
Raptrex, as far as I can see. Yes, this table layout is the only child that has your scrowview. I have exactly the same problem and am very upset trying to solve it.
From LogCat / Debug, it seems that there is something in the fragment manager that calls .AddView (view) in my ScrollView (check the log), it depends on how I change my XML layout. I get this error or not, which, say, sounds pretty absurd!
Any ideas on how? why? I'm listening to...
FATAL EXCEPTION: main java.lang.IllegalStateException: ScrollView can host only one direct child at android.widget.ScrollView.addView(ScrollView.java:219) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:787) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:977) at android.app.BackStackRecord.run(BackStackRecord.java:638) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1309) at android.app.FragmentManagerImpl$1.run(FragmentManager.java:398) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:132) at android.app.ActivityThread.main(ActivityThread.java:4123) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:491) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) at dalvik.system.NativeStart.main(Native Method)