Android CWAC摄像头-不确定是否使用setCameraView()

Android CWAC摄像头-不确定是否使用setCameraView(),android,commonsware-cwac,Android,Commonsware Cwac,我正在使用CameraDemo布局作为一个示例,说明如何正确地将按钮放置在带有摄影机片段的屏幕上 我正在尝试使用setCameraView() 但是,我不能用它,因为它是受保护的。我以CameraDemo-Layout为例。我有自己的CustomCam、CustomCamFragment和CustomCamHost 在onCreateView中的CustomCamFragment中,我试图使用setCameraView,但它未定义。这是错误的还是我应该遵守规则“你不需要叫这个…”因为我不太明白那

我正在使用CameraDemo布局作为一个示例,说明如何正确地将按钮放置在带有摄影机片段的屏幕上

我正在尝试使用setCameraView()

但是,我不能用它,因为它是受保护的。我以CameraDemo-Layout为例。我有自己的CustomCam、CustomCamFragment和CustomCamHost

在onCreateView中的CustomCamFragment中,我试图使用setCameraView,但它未定义。这是错误的还是我应该遵守规则“你不需要叫这个…”因为我不太明白那部分

但是,我不能用它,因为它是受保护的

它被设计为从
CameraFragment
的子类调用,并且子类可以使用
protected
方法

我以CameraDemo-Layout为例

您可以在以下内容的
onCreateView()
中看到对
setCameraView()的调用:

我是否应该遵守“你不必称之为……”的规则,因为我不太理解这一部分

要么您自己(通过构造函数或布局膨胀)创建
CameraView
的实例,要么您不是

如果您正在创建这样一个实例,并且希望使用
CameraFragment
子类,则该子类必须调用
setCameraView()
,传入
CameraView
实例


如果您不创建这样的实例,而是允许
CameraFragment
的stock实现为您创建
CameraView
,则不需要调用
setCameraView()
,部分原因是您没有要设置的
CameraView

我有
公共类CustomCamFragment扩展CameraFragment
,但它不允许我访问
setCameraView
。编辑:啊哈!我正在导入com.commonware.cwac.camera.acl.CameraFragment,但它显然没有setCameraView。@user2676468:是的,这是一个bug。@user2676468:您可以跟踪以保持对它的跟踪。我将期待明天发布包含此修复程序的v0.6.2版。对不起!谢谢我可能不得不调查git帐户,而不是在这里提问。但是,现在我将坚持这样做。我试图在我的活动布局中直接使用CameraView,而不使用CameraFragment,我实现了CameraHostProvider,从重写的方法返回SimpleCameraHost。它不起作用,请任何人告诉我我错过了什么@公用软件
  /**
   * Use this if you are overriding onCreateView() and are
   * inflating a layout containing your CameraView, to tell
   * the fragment the CameraView, so the fragment can help
   * manage it. You do not need to call this if you are
   * allowing the fragment to create its own CameraView
   * instance.
   * 
   * @param cameraView
   *          the CameraView from your inflated layout
   */
  protected void setCameraView(CameraView cameraView) {
    this.cameraView=cameraView;
  }
  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState) {
    View content=inflater.inflate(R.layout.camera, container, false);
    CameraView cameraView=(CameraView)content.findViewById(R.id.camera);

    setCameraView(cameraView);

    return(content);
  }