转自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 );
}
 
}

 

相关文章:

  • 2022-01-23
  • 2022-01-22
  • 2021-07-19
  • 2021-10-25
  • 2021-06-21
  • 2021-09-17
  • 2021-11-24
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-03-31
相关资源
相似解决方案