ViewGroup.resetResolvedTextDirection 中的 Android StackOverflowError
我刚刚去 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 ...
这就是全部 - 没有任何其他信息。
我完全不知道从哪里开始调查这个问题。任何想法都将不胜感激。
I just went to android market to publish an update to my app and noticed there a few new errors reported from existing installs. While I can understand (and attempt to do something about) most of them, this one leaves me rather puzzled:
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 ...
This is all there is - no other information of any kind.
I'm totally stumped as to where to start investigating this. Any ideas are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这似乎是 ICS 中添加的方法,所以它是 4.0 及以上版本。查看 代码 看起来你的层次结构中有某种视图循环,因为它显然是
child.resetResolvedTextDirection();
行执行此操作。换句话说,布局中的一个ViewGroup
类已以某种方式作为子级添加到其自身的某个位置。That appears to be a method added in ICS, so it's 4.0 and over. Looking at the code it seems like you have some kind of view loop in your hierarchy since it's apparently the
child.resetResolvedTextDirection();
line doing it. In other words, one of yourViewGroup
classes in your layout has somehow gotten added as a child to itself somewhere down the line.我找到了问题所在。在我看来,这就像 Android 中的一个错误,当视图的
visibility
显式设置为VISIBLE
但视图本身和视图的父级未添加到主视图时,就会出现该错误。看法。我最终通过将有问题的 ListView 添加到 XML 而不是在代码中创建它并将代码
setVisibility(View.VISIBLE)
移动到将整个视图添加到主视图之后解决了这个问题(即父级层次结构可以从每个子级一直追溯到开始)。至少我不会再收到这个错误了。
I tracked down the problem. It seems to me like a bug in Android, which is exhibited when a View's
visibility
is explicitly set toVISIBLE
but the view itself and the view's parent is not added to the main view.I finally got around the problem by adding the ListView in question to XML instead of creating it in the code and moving the code
setVisibility(View.VISIBLE)
to after the entire view is added to the main view (i.e. parent hierarchy can be traced from each child all the way to the beginning).At least I'm not getting this error any more.
问题是当您膨胀视图时
inflater.inflate(R.layout.view_topic, this);
并且该视图的父级仍然不可见/渲染到舞台上。
确保在父级可见或调用后渲染它
The issue is when you inflate the view such that
inflater.inflate(R.layout.view_topic, this);
and the parent of this view is still not visible / rendered on to the stage.
Make sure you render it after the parent is visible or call