title: Problem with SurfaceHolder.Callback Interface in Android SDK
body: <p>I've been tinkering with the idea of delving into the Android SDK since I got my Droid X a while ago, and just recently acted on it.  I installed the ADT plugin in Eclipse, downloaded and installed the Android SDK (Rev. 11), and tried some stuff out.  I wanted to try 2d graphics out, since they're a huge departure from what I spend my hours on at work (embedded systems development).  </p>
  
  <p>I've tried to follow the tutorial <a href="http://mobile.dzone.com/articles/beginning-android-game" rel="nofollow">here</a>, but can't build due to some errors with two interfaces that are implemented.  I'm trying to build for 2.3.3 on a 64 bit Windows 7 machine.  I'll include the code below, with the <em>important</em> caveat that I'm not a typically Java programmer and something obvious could easily have escaped me.</p>
  
  <p><strong>Drawable Panel.java</strong></p>
  
  <pre><code>package com.android.tutorial;
  
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  
  public abstract class DrawablePanel 
      extends SurfaceView 
      implements SurfaceHolder.Callback, ISurface {
  
      private AnimationThread thread;
  
      public DrawablePanel(Context context) {
          super(context);
          getHolder().addCallback(this);
  
          this.thread = new AnimationThread(getHolder(), this);
      }
  
       @Override
       public void onDraw(Canvas canvas) {
       }
  
       @Override
      public void surfaceChanged(SurfaceHolder holder, int format, int width,
              int height) {
      }
  
      @Override
      public void surfaceCreated(SurfaceHolder holder) {
          thread.setRunning(true);
          thread.start();
      }
  
      @Override
      public void surfaceDestroyed(SurfaceHolder holder) {
          boolean retry = true;
          thread.setRunning(false);
          while (retry) {
              try {
                  thread.join();
                  retry = false;
              } catch (InterruptedException e) {
                  // we will try it again and again...
              }
          }           
      }
  }
  </code></pre>
  
  <p><strong>ISurface.java</strong></p>
  
  <pre><code>package com.android.tutorial;
  
  import android.graphics.Canvas;
  
  public interface ISurface {
      void onInitialize();
      void onDraw(Canvas canvas);
      void onUpdate(long gameTime);
  }
  </code></pre>
  
  <p><strong>AndroidTutorial.java</strong></p>
  
  <pre><code>package com.android.tutorial;
  
  
  import android.app.Activity;
  import android.content.Context;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.os.Bundle;
  
  public class AndroidTutorial extends Activity {
      AnimatedSprite animation = new AnimatedSprite();
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(new AndroidTutorialPanel(this));
      }
  
      class AndroidTutorialPanel extends DrawablePanel {
  
          public AndroidTutorialPanel(Context context) {
              super(context);
          }
  
          @Override
          public void onDraw(Canvas canvas) {
              super.onDraw(canvas);
              AndroidTutorial.this.animation.draw(canvas);
          }
  
          @Override
          public void onInitialize() {
              AndroidTutorial.this.animation.Initialize(
                      BitmapFactory.decodeResource(
                              getResources(), 
                              R.drawable.explosion), 
                              32, 32, 14, 7);
          }
  
          @Override
          public void onUpdate(long gameTime) {
              AndroidTutorial.this.animation.Update(gameTime);
          }
      }
  
  }
  </code></pre>
  
  <p>I'm getting the following error in <code>DrawablePanel.java</code> at the definitions of surfaceChanged(), surfaceCreated(), and surfaceDestroyed():</p>
  
  <pre><code>The method [name of function mentioned above](SurfaceHolder) of type DrawablePanel must override a superclass method.
  </code></pre>
  
  <p>It's the same thing for <code>onInitialize</code> and <code>onUpdate</code> in <code>AndroidTutorial.java</code>. I'm lost since I can copy/paste the same thing at work (ver 10 of the SDK), with no errors.  Any thoughts?</p>