views:

409

answers:

2

Hi,

I created a custom SurfaceView called CaptureView and tried to add it into main.xml file:

<dev.recorder.client.CaptureView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/capturePreview"/>

The application seems to work fine but if I switch from main.xml tab to Layout in Eclipse the text NullPointerException appears instead of layout preview.

In the Activity I binded the controls the following way:

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);
}

Does anyone know how this issue could be solved?

+2  A: 

make sure that you are initializing the view in onFinishInflate and not in the constructor. the layout preview code might initialize your control through a different code path.

Reflog
A: 

It could be a problem of eclipse, refer to the emulator.

LucaB