5

我正在开发一个 Android 应用程序。在我的一项活动中,我正在使用 PullToRefreshListView。有时我的活动出现java.lang.StackOverflowError异常。我试图修复它,我也在谷歌上搜索过,但没有得到完美的解决方案。

我有两个具有相同功能的活动,PullToRefreshListView 具有相同的数据。但我只在一项活动中收到此异常。其他活动工作正常。

这是我的完整 StakeTrace。

请帮我。对不起我的英语不好。

提前谢谢。

java.lang.StackOverflowError  
at android.text.TextLine.handleText(TextLine.java:749) 
at android.text.TextLine.handleRun(TextLine.java:972) 
at android.text.TextLine.measureRun(TextLine.java:416)  
at android.text.TextLine.measure(TextLine.java:295)  
at android.text.TextLine.metrics(TextLine.java:269)  
at android.text.Layout.getLineExtent(Layout.java:942)  
at android.text.Layout.draw(Layout.java:405)  
at android.text.BoringLayout.draw(BoringLayout.java:400)  
at android.widget.TextView.onDraw(TextView.java:5038)  
at android.view.View.draw(View.java:10982)  
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.widget.ListView.drawChild(ListView.java:3223) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.widget.AbsListView.dispatchDraw(AbsListView.java:2092) 
at android.widget.ListView.dispatchDraw(ListView.java:3218) 
at com.handmark.pulltorefresh.library.PullToRefreshListView$InternalListView.dispatchDraw(PullToRefreshListView.java:293) 
at android.view.View.draw(View.java:10985) 
at android.widget.AbsListView.draw(AbsListView.java:3398) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:928) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.widget.FrameLayout.draw(FrameLayout.java:450) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.getDisplayList(View.java:10419) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2850) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489) 
at android.view.View.draw(View.java:10985) 
at android.widget.FrameLayout.draw(FrameLayout.java:450) 
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2126) 
at android.view.View.getDisplayList(View.java:10421) 
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:842) 
at android.view.ViewRootImpl.draw(ViewRootImpl.java:1943) 
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1667) 
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4424) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

6

发生 StackOverflow 异常的原因之一是由于 Layouts 的嵌套。但是这个问题只会在 4.0 及以下版本出现,超出这个 stackoverflow 异常不会发生太多。检查您的 xml 中是否有多个嵌套布局以避免此问题。请发布您的 xml 以提供进一步帮助。

于 2014-09-16T07:08:50.960 回答