Android StackOverflowError in ViewGroup.resetResolvedTextDirection

谁说我不能喝 提交于 2019-12-05 05:27:21

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 your ViewGroup classes in your layout has somehow gotten added as a child to itself somewhere down the line.

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 to VISIBLE 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.

Archana Bajaj

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

View child = inflater.inflate(R.layout.view_topic, null); // null will give warning but it wont throw an exception
        this.addView(child);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!