Custom view * is not using the 2- or 3-argument View constructors; XML attributes will not work

转自http://igoesolutions.com/blog/2011/06/20/custom-view-is-not-using-the-2-or-3-argument-view-constructors-xml-attributes-will-not-work/

 

写三个构造函数就OK了:

public class ExtendedClass extends Button {

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

 

posted @ 2012-08-18 22:15  honging  阅读(2219)  评论(0编辑  收藏  举报