java.lang.IllegalStateException:指定的孩子已经有一个父。你必须先调用removeView()对孩子的父 [英] java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first

查看:204
本文介绍了java.lang.IllegalStateException:指定的孩子已经有一个父。你必须先调用removeView()对孩子的父的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的code:

Frame.gameController.test();
setContentView(Frame.world.getScreen());
Frame.world.setRunning(true);

在第二行我收到以下错误:

On the second line I am getting the following error:

ERROR/AndroidRuntime(15229): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

谁能帮我解决吗? previously它工作得很好,这个问题开始,当我把它的其他活动。

Can anyone help me solve it? Previously it was working just fine, the problem starts when I take it in another activity.

我使用的是Android 2.2的。

I'm using android 2.2.

推荐答案

您不能使用在多个业务相同的看法。相反,你应该创建视图的新实例。

You can't use the same view in multiple activities. Instead you should create a new instance of the view.

这篇关于java.lang.IllegalStateException:指定的孩子已经有一个父。你必须先调用removeView()对孩子的父的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆