Android 如果自定义surfaceView是活动中的嵌套类,如何初始化它?

Android 如果自定义surfaceView是活动中的嵌套类,如何初始化它?,android,surfaceview,android-view,nested-class,xml-layout,Android,Surfaceview,Android View,Nested Class,Xml Layout,我有一个自定义的SurfaceView,如下所示: public class GFXSurface extends Activity implements OnTouchListener { . . GameSurface gameSurfaceView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedIns

我有一个自定义的SurfaceView,如下所示:

public class GFXSurface extends Activity implements OnTouchListener 
{
    .
    .
    GameSurface gameSurfaceView;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.game); 
        gameSurfaceView = (GameSurface)findViewById(R.id.svgame);
        fullscreen();
        initialize();
    }
    .
    .
    .
    public class GameSurface extends SurfaceView implements Runnable 
    {
        .
        .
        public GameSurface(Context context) 
        {
            super(context);
            ourHolder = getHolder();
        }
        .
        .
        .
    }
}
我的问题是如何在xml布局中引用它

我正在使用xml布局,因为我需要添加一些 表面上的东西

我尝试了几种方法,但都失败了

这不起作用:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

  <com.bla.bla.GFXSurface.GameSurface
    android:id="@+id/svgame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
 .
 .
 .
</FrameLayout>

.
.
.

非常感谢你的帮助

您的
游戏界面
类需要是静态的。不能在布局中使用非静态嵌套类,因为需要外部类实例来创建此类的对象