在活动组中添加新活动时出现java.lang.StackOverflowError

时间:2011-11-23 06:30:05

标签: android activitygroup android-tabactivity

我正在 stackoverflow error

我的布局结构如下

<TabActivity>
    <tab1><Activity name="home">
    <tab2><Activitygroup><activity name="XYZ">
                <activity name="options">
                <activity name="thankYou">
    <tab3>
        <TabActivity>
            <tab3.1><Activitygroup><activities name="PQR">
            <tab3.2><activity name="today">
            <tab3.3><activity name="history">
            <tab3.4><Activitygroup>
                    <activity name="reOrder"> from this I will open 
                    <Activity name="options">
        <TabActivity>
    <tab4><Activitygroup><activities name="ABC">
    <tab5><Activity name="setting">
<TabActivity>

我在tab3.4时遇到错误。 我在Activitygroup中有一个活动,现在我在此活动组中添加新活动 下一个按钮点击了活动组tab3.4中的第一个活动。

我调试了它并检查直到onResume()它工作正常但在此之后它是触发错误。 在收到错误之前,我也可以看到新的活动。

此外,如果我打开另一个活动,它工作正常。那个时候它正在发挥作用。

堆栈跟踪

11-23 07:06:24.912: WARN/dalvikvm(1783): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
11-23 07:06:24.912: ERROR/AndroidRuntime(1783): Uncaught handler: thread main exiting due to uncaught exception
11-23 07:06:24.943: ERROR/AndroidRuntime(1783): java.lang.StackOverflowError
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.text.Styled.measureText(Styled.java:371)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.text.Layout.measureText(Layout.java:1601)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.text.Layout.getLineMax(Layout.java:655)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.text.Layout.getLineWidth(Layout.java:637)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.TextView.getRightFadingEdgeStrength(TextView.java:6713)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6608)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6641)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6641)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.View.draw(View.java:6538)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewRoot.draw(ViewRoot.java:1349)
11-23 07:06:24.943: ERROR/AndroidRuntime(1783):     at android.view.ViewRoo

请帮我解决这个问题。

感谢。

1 个答案:

答案 0 :(得分:4)

我担心您需要任何其他解决方法,而不是将ActivityGroup嵌套在另一个ActivityGroup中 因为android不支持太多嵌套ViewGroup可能是一些内存问题。

有时这些标签在模拟器上完美运行,但在真实设备上部署时会显示StackOverflowException

最简单的方法是更改​​Activity流量(例如,将子ActivityGroup移出父ActivityGroup并在整个屏幕中显示)

For further see here, answer by Romain Guy