如何使用布局自己的观点? [英] How to use own view in layout?
本文介绍了如何使用布局自己的观点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个这样的类
public final class MyView extends View {
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
[...]
}
[...]
}
然后我想我的layout.xml内使用
and then I want to use it within my 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告诉我在错误日志
But Eclipse tells me in the error log
AndroidManifest:忽略未知 com.hitziger.bar code.MyView'XML 元素
AndroidManifest: Ignoring unknown 'com.hitziger.barcode.MyView' XML element
我怎样才能让一个布局中的MyView的accessable?我必须在其他地方发表这个类?
How can I make MyView accessable within a layout? Do I have to publish this class elsewhere?
推荐答案
您应该写这样的:
<view class="com.hitziger.barcode.MyView"...
这篇关于如何使用布局自己的观点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文