title: How to control the Android SurfaceView (canvas) redraw
body: <p>I'm have a couple of images in a grid. 
  Looks something like this: 
  [http://cdn.thenextweb.com/wp-content/blogs.dir/1/files/2013/06/jolla4.jpg][1]</p>
  
  <p>Instead of using android Gridview i have used a canvas, because the icons need to be animated. I read that i needed to use the canvas for games.</p>
  
  <p>I am using a SurfaceView (in combination with a thread) to draw the images on the screen.</p>
  
  <pre><code> class MySurface extends SurfaceView implements SurfaceHolder.Callback {
  @Override
      public void onDraw(Canvas canvas) {
          //here i create the bitmaps and draw the icons on the screen.
  
  }
  @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) {}
          }
      }
  </code></pre>
  
  <p>This all works fine. Mysurface is called from within my main activity with the code: </p>
  
  <pre><code>setContentView(new MySurface());
  </code></pre>
  
  <p>The problem is the canvas of the surfaceview is redrawn at random. I want to make it so i can decide when the canvas is redrawn and how many times. How call the onDraw function from within the main activity? I don't know how to do that.</p>
  
  <p>I know in the thread is is done with </p>
  
  <blockquote>
    <p>mySurface.onDraw(c);</p>
  </blockquote>