Custom SurfaceView with Fragments


I am trying to implement a custom SurfaceView as one of the views within the layout for a Fragment, very similar to this: … urfaceview

The problem is that none of the SurfaceHolder callbacks (surfaceCreated/surfaceChanged/surfaceDestroyed) get called. With Activities, there is no problem; it appears that the surface gets created (and callbacks are invoked) after you call setContentView() with the layout id of the XML containing the SurfaceView, in Activity.onCreate().

As far as I can tell, the correponding operation with fragments is the addition of the fragment to the hosting Activity’s fragmentContainer layout like so:

This does NOT cause the SurfaceHolder callbacks to get called, however. Any ideas regarding this would be much appreciated!