使用findViewById查找自定义view时返回NULL有关问题

使用findViewById查找自定义view时返回NULL问题

今天碰到一个findViewById查找自定义view时返回NULL的问题,经过排查发现是构造函数调用错误:

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

QiuQianAnimationView这个之定义view中,调用父类的构造函数没有传入AttributeSet

改为:

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

即可