我正在尝试为 ButterKnife 创建一个自定义侦听器注释,但我无法使其工作。这是我的注释:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
@ListenerClass(
targetType = "com.maddogs.mymoney.views.CameraImageView",
setter = "setCameraImageViewListener",
type = "com.maddogs.mymoney.views.CameraImageViewListener",
method = @ListenerMethod(
name = "onCloseClick",
parameters = {"com.maddogs.mymoney.views.CameraImageView"},
returnType = "boolean",
defaultReturn = "true"
)
)
public @interface OnCloseClick {
int[] value() default { View.NO_ID };
}
还有我的 CameraImageView:
@Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction() != MotionEvent.ACTION_DOWN
&&(event.getX(0) <= this.getWidth()
&& event.getY(0) >= 0)
&& event.getX(0) >= this.getWidth() - closeBitmap.getWidth()
&& event.getY(0) <= closeBitmap.getHeight()){
if(listener == null)
throw new NullPointerException("CameraImageViewListener cannot be null");
return listener.onCloseClick(this);
}
return super.onTouchEvent(event);
}
public void setCameraImageViewListener(CameraImageViewListener listener) {
this.listener = listener;
}
public static interface CameraImageViewListener{
boolean onCloseClick(CameraImageView view);
}
还有我的项目结构:
侦听器始终为空。怎么了??谢谢