I want to draw multiple lines on the view with different colors and undo,redo the paths in android.

I use the bitmap paint option, each path has a unique color but undo,redo is not working.

Here is my code of bitmappaint:

```
public MyView(Context context, Object object) {
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);

    mPath = new Path();
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(0xFFFFFF00);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(3);

    mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
    mCanvas = new Canvas(mBitmap);
}

protected void onSizeChanged(int w, int h, int oldw, int oldh) 
{
    super.onSizeChanged(w, h, oldw, oldh);
}

protected void onDraw(Canvas canvas) 
{
    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    for (Path p : paths)
    {
        canvas.drawPath(p, mPaint);
    }
    canvas.drawPath(mPath, mPaint);
}

public boolean onTouchEvent(MotionEvent event)
{
    float x = event.getX();
    float y = event.getY();
    int action = event.getAction();
    int action1=event.getAction();
    switch (event.getAction())
    {
    case MotionEvent.ACTION_DOWN:
        undonePaths.clear();
        mPath.reset();
        mPath.moveTo(x, y);
        mX = x;
        mY = y;
        startPoint = new PointF(event.getX(), event.getY());
        endPoint = new PointF();
        invalidate();
        //   isDrawing = true;
        break;
    case MotionEvent.ACTION_MOVE:
        float dx = Math.abs(x - mX);
        System.out.println("action move");
        float dy = Math.abs(y - mY);
        if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE)
        {
            //  currentDrawingPath.path.quadTo(mX,mY,(x + mX)/2, (y + mY)/2);
        }
        mX = x;
        mY = y;
        endPoint.x = event.getX();
        endPoint.y = event.getY();
        isDrawing = true;
        invalidate();
        break;
    case MotionEvent.ACTION_UP:
        mPath.lineTo(mX, mY);
        paths.add(mPath);
        mPath = new Path();
        //  mCanvas.drawPath(mPath, ppaint);
        endPoint.x = event.getX();
        endPoint.y = event.getY();
        isDrawing = false;
        invalidate();
        break;
    default:
        break;
    }       
}

```

![output of bitmappaint canvas](https://i.stack.imgur.com/9aQvE.png)

without bitmap using i faced the color problem if i select a blue color for a path means all the previous paths will be changed to blue color;

Here is my code

```
protected void onDraw(Canvas canvas) 
{
    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    for (Path p : paths)
    {
        canvas.drawPath(p, mPaint);
    }
    canvas.drawPath(mPath, mPaint);
}

```

![output of without bitmap using canvas drawing](https://i.stack.imgur.com/eDp5Y.png)

Can anyone help me to draw multiple paths with different color of unique paths in android?