您的位置:首页 > 其它

Unable to start activity ComponentInfo……加载含有自定义View类的xml文件出错

2015-12-19 15:52 316 查看
自定义了ShowWindow类,继承自View类,加载含有自定义View类的xml文件出错

最后看api发现构建custom view步骤如下:

Subclass a View
Define Custom Attributes
Apply Custom Attributes to a View
Add Properties and Events
Design For Accessibility

其中第第一条说明如下

All of the view classes defined in the Android framework extend 
View
.
Your custom view can also extend 
View
 directly,
or you can save time by extending one of the existing view subclasses, such as
Button
.

To allow the Android Developer Tools to interact with your
view, at a minimum you must provide a constructor that takes a 
Context
 and
an 
AttributeSet
 object as parameters.
This constructor allows the layout editor to create and edit an instance of your view.

自定义的view类至少要有含有偶context和attributeset的构造函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: