7

我刚刚去 android 市场发布了对我的应用程序的更新,并注意到现有安装报告了一些新错误。虽然我可以理解(并尝试做一些事情)其中的大多数,但这让我很困惑:

java.lang.StackOverflowError
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
... this line repeats about 200 times or so ...

这就是全部 - 没有任何其他信息。

我完全不知道从哪里开始调查这个。任何想法都非常感谢。

4

3 回答 3

10

这似乎是ICS中添加的一种方法,所以它是4.0及以上。查看代码,您的层次结构中似乎有某种视图循环,因为它显然是执行它的child.resetResolvedTextDirection();行。换句话说,ViewGroup你布局中的一个类不知何故被作为一个孩子添加到自己的某个地方。

于 2012-02-07T17:18:38.210 回答
1

我追查了问题。在我看来,这就像 Android 中的一个错误,当视图visibility被显式设置为VISIBLE但视图本身和视图的父级未添加到主视图时,就会出现这种错误。

我终于通过将有问题的 ListView 添加到 XML 而不是在代码中创建它并将代码移动setVisibility(View.VISIBLE)到将整个视图添加到主视图之后解决了这个问题(即可以从每个子视图一直跟踪父层次结构到开始)。

至少我不再收到此错误。

于 2012-02-24T15:19:19.810 回答
1

问题是当您膨胀视图时,该inflater.inflate(R.layout.view_topic, this); 视图的父级仍然不可见/呈现在舞台上。

确保在父级可见或调用后渲染它

View child = inflater.inflate(R.layout.view_topic, null); // null will give warning but it wont throw an exception
        this.addView(child);
于 2014-08-27T12:25:40.373 回答