1

I have a custom SurfaceView that looks like this:

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

my question is how can I reference it in my xml layout?

i am using the xml layout cause i need to add some things on top of that surface view

and i tries several ways but all failed...

this doesnt work :

<?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>

thank you very much for the help!!!!

Leon
  • 55
  • 1
  • 8

1 Answers1

2

Your GameSurface class need to be static. You can't use non-static nested classes in layouts because you need outer class instance to create an object of this class.

Andrei Mankevich
  • 2,253
  • 16
  • 15