title: Drawing does not remain on View
body: <p>I got an Activity that contains a CustomImage (extends View) on which i try to draw, i can see the lines but on my touchUp they disappear.
   I set the paint like this:</p>
  
  <pre><code>paint = (CustomImage) findViewById(R.id.paint);
  mPaint = new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setDither(true);
  mPaint.setColor(0xFF000000);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeJoin(Paint.Join.ROUND);
  mPaint.setStrokeCap(Paint.Cap.ROUND);
  mPaint.setXfermode(null);
  mPaint.setAlpha(0xFF);
  mPaint.setMaskFilter(null);
  mPaint.setStrokeWidth(50);
  paint.setPaint(mPaint);
  </code></pre>
  
  <p>This is my CustomImage class:</p>
  
  <pre><code>public class CustomImage extends View {
  
  private Bitmap bitmap;
  
  public Context context;
  
  Paint paint = new Paint();
  
  private Canvas canvas = new Canvas();
  
  private Path mPath = new Path();
  
  private float mX, mY;
  
  private static final float TOUCH_TOLERANCE = 4;
  
  private float screenDensity;
  
  int height, width;
  
  public CustomImage(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
      init(context);
  }
  
  public CustomImage(Context context, AttributeSet attrs) {
      super(context, attrs);
      init(context);
  }
  
  public CustomImage(Context context) {
      super(context);
      init(context);
  }
  
  private void init(Context context) {
      this.context = context;
  }
  
  public void setImg(Context context, Canvas canvas, Bitmap bitmap, int width, int height) {
      this.bitmap = bitmap;
      canvas.drawBitmap(bitmap, 0, 0, null);
  }
  
  public void setPaint(Paint paint) {
      this.paint = paint;
  }
  public void getBitmap(Bitmap bitmap) {
      this.bitmap = bitmap;
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      canvas.drawBitmap(bitmap, 0, 0, null);
      canvas.drawPath(mPath, paint);
  
  }
  
  private void touch_start(float x, float y) {
      mPath.reset();
      mPath.moveTo(x, y);
      mX = x;
      mY = y;
  }
  
  private void touch_move(float x, float y) {
      float dx = Math.abs(x - mX);
      float dy = Math.abs(y - mY);
      if ((dx &gt;= TOUCH_TOLERANCE) || (dy &gt;= TOUCH_TOLERANCE)) {
          mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
          mX = x;
          mY = y;
      }
  }
  
  private void touch_up() {
      mPath.lineTo(mX, mY);
      mPath.moveTo(mX, mY);
      canvas.drawPath(mPath, paint);
      mPath.reset();
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      float x = event.getX();
      float y = event.getY();
      switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
          touch_start(x, y);
  
          invalidate();
          break;
      case MotionEvent.ACTION_MOVE:
          touch_move(x, y);
          invalidate();
          break;
      case MotionEvent.ACTION_UP:
          touch_up();
          invalidate();
          break;
      }
      return true;
  }
  }
  </code></pre>
  
  <p>First i set an background image on the View. and then i should be able to draw over that picture. The app draws the lines but they disappear on touchup. How can i avoid that?</p>