我创建了一个这样的类
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: Ignoring unkNown
‘com.hitziger.barcode.MyView’ XML
element
如何在布局中使MyView可访问?我是否必须在其他地方发表这门课程?
解决方法
你应该写它:
<view class="com.hitziger.barcode.MyView"...