我有一个自定义SurfaceView
我希望显示在Fragment
中显示,但是当我添加它时,应用程序崩溃了。
自定义SurfaceView
代码如下:
public class CameraFocusIndacatorSurfaceView extends SurfaceView implements Runnable {
private final Paint paint;
private final SurfaceHolder mHolder;
private final Context context;
@Override
public void run(){}
public CameraFocusIndacatorSurfaceView(Context context) {
super(context);
mHolder = getHolder();
this.context = context;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
init();
}
private void init(){
mHolder.setFormat(PixelFormat.TRANSPARENT);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
//do some stuff
}
}
在Fragment
所在的SurfaceView
中调用此行时,应用会崩溃:
View view = inflater.inflate(R.layout.fragment_attachment_upload_camera, container, false);
这是Fragment
:
构造函数没有被拾取,或者是什么?