您的位置:首页 > 产品设计 > UI/UE

Android 自定义控件build时提示Custom view * is not using the 2- or 3-argument View constructors; XML attribut

2013-09-29 11:29 453 查看
如果你的控件继承自view那么需要写上三个构造函数,其它的可以查看源码,只要把全部的继承函数都写上去就可以了。

View的三个继承函数是:

public WiperSwitch(Context context) {
super(context);
init();
}

public WiperSwitch(Context context, AttributeSet attrs){
super(context,attrs);
init();
}

public WiperSwitch(Context context,AttributeSet attrs,int defStyle){
super(context,attrs,defStyle);
init();
}


说明:这里的init是我的控件要执行的一个默认方法,其它的控件同理,只要写上全部的构造函数就不会把这样的错误了。

(完)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 继承
相关文章推荐