偶尔的二进制XML文件行#XX:错误膨胀类< unknown>
我有一个主要活动,它包含主菜单。此菜单有一个选项可以启动第二个活动,这是一个
SurfaceView
后代。
我多次收到此错误,但并非总是如此。我需要通过第一个活动的菜单按钮执行调用第二个活动的过程,然后返回到第一个活动。最终(通常在第7次重复),错误发生在第2次。活动正在启动。将调试器打开,电话屏幕变黑并被阻止大约30秒或更长时间,然后我会看到关闭它的对话框。在调试器中,应用程序停止此异常。
我的第二个活动的布局文件是:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.myapp.MySecActivity
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/sec_view"/>
</FrameLayout>
我有一个类MySecActivity
,在构造函数上加载此布局。
我发现我在setContentView
上得到了InflateException
。我正在检查我传递给setContentView
的id,并且在所有条件下它都是相同的,而不是null:
int id = getResources().getIdentifier("mylayout", "layout", getPackageName());
if (id<= 0) {
id= 0; // just for debugging
} else {
try {
setContentView(id);
} catch (InflateException e) {
error = true;
}
}
没有找到相关结果
已邀请:
1 个回复
苦诫
前奏以及设置xml命名空间。你在做这个吗?
如果
不是你的根元素,那么如果我们要查看它,请尝试粘贴整个布局。