title: Android Poor performance of surfaceview in Listview
body: <p>I have a android app having a layout containing a Listview, which is inflated with</p>
  
  <pre><code>      LayoutInflater inflater = getLayoutInflater();
        row = inflater.inflate(R.layout.disc_row, parent, false);
  </code></pre>
  
  <p>the "R.layout.disc_row" is containing a SurfaceView drawing a canvas. so each row within the ListView is containing a Canvas. while scrolling the list the canvas is staying at its place while the other elements of the row are scrolling. I think its a poor behaviour of the device. the same app is not drawing anything on the emulator until clicking on a ListItem.</p>
  
  <p>Is there any better strategy for drawing inside ListViews (no Bitmap, just some lines) maybe with Paint?
  emulator sys it is doing too much work in the activity.</p>
  
  <p>thanks in advance</p>
  
  <p>attached CLASS</p>
  
  <pre><code>public class DrawDiscInListView extends SurfaceView implements
      SurfaceHolder.Callback {
  
  private static final String TAG = "DISCONT SurfaceView";
  
  public DrawDiscInListView(Context context, AttributeSet attrs) {
      super(context, attrs);
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
      tryDrawing(holder);
  }
  
  @Override
  public void surfaceChanged(SurfaceHolder holder, int frmt, int w, int h) {
      tryDrawing(holder);
  }
  
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
  }
  
  private void tryDrawing(SurfaceHolder holder) {
      Log.i(TAG, "Trying to draw...");
  
      Canvas canvas = holder.lockCanvas();
      if (canvas == null) {
          Log.e(TAG, "Cannot draw onto the canvas as it's null");
      } else {
          drawMyStuff(canvas);
          holder.unlockCanvasAndPost(canvas);
      }
  }
  
  private void drawMyStuff(final Canvas canvas) {
      Random random = new Random();
      Log.i(TAG, "Drawing...");
      canvas.drawRGB(255, 128, 128);
  }
  </code></pre>
  
  <p>}</p>