我创建了一个自定义SurfaceView名称CaptureView并尝试将其添加到main.xml文件中:
<dev.recorder.client.CaptureView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/capturePreview"/>
该应用程序似乎工作正常,但如果我main.xml在 Eclipse 中从选项卡切换到布局,NullPointerException则会出现文本而不是布局预览。
在活动中,我通过以下方式绑定了控件:
setContentView(R.layout.main);
bindControls();
private void bindControls()
{
videoPreview = (CaptureView)findViewById(R.id.capturePreview);
txtstatus = (TextView)findViewById(R.id.txtMode);
txtTimer = (TextView)findViewById(R.id.txtTime);
}
有谁知道如何解决这个问题?