-1

我正在尝试做一个按钮,而不是它的功能是转到 TabWidget 中的上一个活动

        btnVolver.setOnClickListener(new OnClickListener() 
        {
            @Override
            public void onClick(View arg0) 
            {
                String className = getIntent().getStringExtra("webpush");
                Class<?> webpushClass = null;
                try {
                    webpushClass = Class.forName(className);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                 Intent intent = new Intent(getApplicationContext(), webpushClass); 
                 intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//               intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//               intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
//               webPushActivity.this.finishActivity(RESULT_OK);
                 View vista = getLocalActivityManager().startActivity("prueba",
                         intent)
                            .getDecorView();
                       setContentView(vista);

A--> 实际活动。B--> 上一个活动

但是当我从 A 到 B,从 B 到 A,从 A 到 B(第三次点击)时,我得到下一个错误:

 06-20 09:23:20.256: E/AndroidRuntime(554): FATAL EXCEPTION: main
 06-20 09:23:20.256: E/AndroidRuntime(554):
 java.lang.StackOverflowError
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.text.Styled.measureText(Styled.java:430)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.text.Layout.measureText(Layout.java:1655)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.text.Layout.getLineMax(Layout.java:689)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.text.Layout.draw(Layout.java:340)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.text.BoringLayout.draw(BoringLayout.java:365)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.TextView.onDraw(TextView.java:4050)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6740)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1638)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.drawChild(ViewGroup.java:1640)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.View.draw(View.java:6743)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.widget.FrameLayout.draw(FrameLayout.java:352)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewRoot.draw(ViewRoot.java:1407)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewRoot.performTraversals(ViewRoot.java:1163)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.view.ViewRoot.handleMessage(ViewRoot.java:1727)

 06-20 09:23:20.256: E/AndroidRuntime(554):     at
 android.os.Handler.dispatchMess

谢谢

4

2 回答 2

0

StackOverflowError可能是由太多嵌套视图引起的(您的 logcat 内容也暗示了这一点)。

查看以下链接以获取更多参考:

Android StackOverflow 错误

java.lang.StackOverFlow 错误。怀疑浏览量过多?

Stackoverflow:由嵌套视图引起?

于 2012-06-20T09:49:36.020 回答
0

我不确定,但您是否尝试开始另一个活动并将视图设置为当前活动?

于 2012-06-20T09:54:36.717 回答