Skip to content Skip to sidebar Skip to footer

Android Surfaceview Empty

I am trying to make a simple 2D Android game. In this, game I'm trying to make some buttons to control the character, while the character is shown in a SurfaceView. Currently, the

Solution 1:

Your view in the layout is a SurfaceView, not a GameView. You need to change that:

        <your.package.name.GameView
            android:id="@+id/snake_surface"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.3" />

And replace your.package.name with the actual name of the package containing GameView.

Also, the line GameView gm = ... needs to go aftersetContentView.

And lastly, don't forget to call gm.invalidate() when you've modified the items that will be drawn!

Post a Comment for "Android Surfaceview Empty"