EditText导致旧设备上的StackOverflowError

时间:2013-06-13 07:58:24

标签: java android android-layout stack-overflow

我正在使用第三方工具创建与you can see it here类似的TableView

我已经对这个软件包进行了很多编辑,并添加了一行具有EditText的功能。我在不同的设备上进行了测试,效果很好。现在我遇到的问题是,如果我在嵌套布局中有这个UITableView并给出一行编辑文本,当用户在某些旧设备上单击EditText时,它会导致堆栈溢出。

这是一个片段。结构看起来像这样

(1)(2)(3)(4) RelativeLayout - > RelativeLayout - > RelativeLayout - > ScrollLayout - > UITableView的

这背后有一些背景,但长话短说我需要所有这些布局,所以删除其中一个不是一个选项。这很令人沮丧,好像我删除了一个RelativeLayouts,应用程序没有崩溃。

Android UITableView也使用多个LinearLayouts设置。理想情况下,如果我可以将LinearLayout设置为能够滚动,这将是很好的,这样我可以删除ScrollLayout并且问题将会消失,但遗憾的是我不相信这是可能的。

我得到的错误是

06-13 07:42:23.399: E/AndroidRuntime(1429): FATAL EXCEPTION: main
06-13 07:42:23.399: E/AndroidRuntime(1429): java.lang.StackOverflowError
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2758)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:2759)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView$HandleView.isPositionVisible(TextView.java:8228)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView$HandleView.moveTo(TextView.java:8245)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView$HandleView.positionAtCursor(TextView.java:8340)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView$InsertionPointCursorController.updatePosition(TextView.java:8401)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView.updateCursorControllerPositions(TextView.java:4292)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.TextView.onDraw(TextView.java:4281)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6986)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6989)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6989)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:7093)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.FrameLayout.draw(FrameLayout.java:361)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.ScrollView.draw(ScrollView.java:1421)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6989)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6989)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.View.draw(View.java:6989)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.widget.FrameLayout.draw(FrameLayout.java:361)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
06-13 07:42:23.399: E/AndroidRuntime(1429):     at android.view.Vi

我在许多较新的设备,Nexus,HTC等上测试了这一点,没有问题。但是,当我在旧设备上测试时,Sony Ericson Mini Pro 2会发生此错误。我想确保此应用在旧设备上不会崩溃,目前应用支持2.3.3 +

有没有人知道这个递归调用会发生什么导致旧设备崩溃?反正是为了防止这种情况。

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

您所拥有的布局太深,无法处理某些设备。您有4个布局来自您发布的内容(仅来自片段?如果是,那么您还有来自活动的布局)+ UITableView。现在我不知道你做了什么改变但是从UITableView的代码中快速查看并不是很有效。 UITableView仅将LinearLayout扩展为另一个布局,因为其内容由LinearLayout包裹另一个Linearlayout组成。所以UITableView增加了另外三个额外的布局,没有提及它的内容。

要么删除UITableView(你确定你不能使用ListView(可能会杀死所有性能问题/异常)),修改并改进它以便它不会添加布局中的多个级别或您保留它并修改布局的其余部分以提高效率。