本文介绍了ScrollView:java.lang.StackOverflowError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有许多视图的ScrollView,如果我开始活动,则经过一些滚动后会得到:

I got a ScrollView with many Views and if i start the activity i got this after some scrolling:

04-10 20:11:42.480: E/AndroidRuntime(2089): FATAL EXCEPTION: main
04-10 20:11:42.480: E/AndroidRuntime(2089): java.lang.StackOverflowError
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.addFocusables(View.java:3654)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:637)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.addFocusables(ViewGroup.java:618)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.getFocusables(View.java:3612)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.FocusFinder.findNextFocus(FocusFinder.java:109)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.FocusFinder.findNextFocus(FocusFinder.java:93)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:476)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.focusSearch(ViewGroup.java:478)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.focusSearch(View.java:3547)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.TextView.onCreateInputConnection(TextView.java:4662)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:945)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1129)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:542)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.TextView.onDraw(TextView.java:4173)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:6933)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:7039)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.ScrollView.draw(ScrollView.java:1415)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.View.draw(View.java:6936)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
04-10 20:11:42.480: E/AndroidRuntime(2089):     at android.view.ViewGroup.drawChild(

为什么我会收到此错误提示?

Why m I getting this error any idea?

推荐答案

您的UI视图树太深. addFocusables递归(显然)到View布局树中,并且Android的堆栈大小非常有限.更改布局以减少嵌套,而增加平面布局.您可能需要编写自定义布局才能获得所需的布局而无需嵌套.

Your UI View tree is too deep. addFocusables is recursive (obviously) into the View layout tree and Android has a fairly limited stack size. Change your layout to do less nesting and more of a flat layout. You may need to write a custom layout to get the layout you want without nesting.

这篇关于ScrollView:java.lang.StackOverflowError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 23:37