【发布时间】:2011-07-27 17:20:41
【问题描述】:
我创建了一个这样的类
public final class MyView extends View {
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
[...]
}
[...]
}
然后我想在我的 layout.xml 中使用它
<?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.hitziger.barcode.MyView
android:id="@+id/my_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
但是 Eclipse 在错误日志中告诉我
AndroidManifest:忽略未知 'com.hitziger.barcode.MyView' XML 元素
如何使 MyView 在布局中可访问?我必须在其他地方发布这个课程吗?
【问题讨论】:
-
你能尝试重建你的项目并部署它吗?好像eclipse搞砸了……
-
每次我遇到这种情况时,结果证明我输入了错误的包名或类名。您能否从 .java 文件、类声明以及引用该类的实际 XML 行中剪切并粘贴实际的包行?