2011-11-23 31 views
3

增加新的活動我得到stackoverflow errorjava.lang.StackOverflowError的,而在活動組

我的佈局結構如下

<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 

請幫我從這個問題。

謝謝。

回答

4

恐怕你需要在另一個ActivityGroup 任何其他的解決辦法,而不是嵌套ActivityGroup由於Android不支持過多的嵌套ViewGroup可能會出現一些內存問題。

有些時候這些標籤可以在模擬器上很好地工作,但在真實設備上部署時會顯示出明顯的StackOverflowException

所以,最簡單的是改變Activity流(例如讓孩子ActivityGroup了父母ActivityGroup的,並顯示在整個屏幕)

For further see here, answer by Romain Guy

+0

好一個阿迪爾+1了點。 –

+0

是啊你是對的它是視圖組的多個層次結構的問題。我刪除了一些內部佈局,現在它工作正常。謝謝。 – Dharmendra

+0

@Dharmendra:請確保您的代碼也在真實設備上運行。 –

相關問題