如何使用CameraPreview实例“SurfaceHolder”覆盖片段

时间:2014-05-27 15:38:50

标签: java android android-fragments surfaceview surfaceholder

如下面的代码所示,我想将cameraPreview添加到类扩展fragment,其布局中有<surfaceView>。我创建了实现surfaceHolder.callback的类,我想将它的实例添加到surfaceview,它是扩展fragment的类布局中的标记。

1)我可以通过设置实现surfaceholder.callbacksurfaceview的类的对象来显示摄像机预览吗?或者我扩展fragment的类应该实现surfaceholder.callback

Class_extends_Fragment:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);

    mCameraPreview = new CustomCameraView(getActivity());
    SurfaceView sv = (SurfaceView) getView().findViewById(R.id.surfaceView);
}

0 个答案:

没有答案