title: Change color without affecting anything previously drawn
body: <p>I have the following <code>CustomView</code> I am using for painting in my app:</p>
  
  <pre><code>package com.test.testing;
  
  import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.Path;
  import android.graphics.Paint.Style;
  import android.view.MotionEvent;
  import android.widget.TextView;
  
  public class CustomView extends TextView {
      Paint paint;
      Path path;
      float x = 0;
      float y = 0;
      private int cWhite = Color.WHITE;
  
      public CustomView(Context context) {
          super(context);
          paint = new Paint();
          path= new Path();
          paint.setAlpha(255);
          paint.setColor(cWhite);
          paint.setStyle(Style.STROKE);
          paint.setStrokeWidth(20);
      }
  
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          canvas.drawPath(path,paint);
          canvas.drawCircle(x, y, 10, paint);
      }
  
      public boolean onTouchEvent(MotionEvent event) {
          int action = event.getAction();
          switch (action) {
          case MotionEvent.ACTION_DOWN:
              path.moveTo(event.getX(), event.getY());
              path.lineTo(event.getX(), event.getY());
              break;
          case MotionEvent.ACTION_MOVE:
              x = event.getX();
              y = event.getY();
              path.lineTo(x, y);
              invalidate();
              break;
          case MotionEvent.ACTION_UP:
              path.lineTo(event.getX(), event.getY());
              break;
          case MotionEvent.ACTION_CANCEL:
              break;
          default:
              break;
          }
          return true;
      }
  }
  </code></pre>
  
  <p>I setup a <code>FrameLayout</code> which keeps the canvas for drawing in my XML:</p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/viewd"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="3"
      android:orientation="vertical" &gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>I call inside my <code>Activity</code> to get the view to enable the user to draw on:</p>
  
  <pre><code>layout = (FrameLayout)findViewById(R.id.viewd);
  //layout.removeAllViews();
  view = new CustomView(Activity.this);
  view.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
  layout.addView(view);
  </code></pre>
  
  <p>I have different color option that user can choose from to change the paint stroke color in a <code>Dialog</code> within my <code>Activity</code>:</p>
  
  <pre><code>public void colorHandle() {
      // custom dialog
      final Dialog dialog = new Dialog(this);
      dialog.setContentView(R.layout.colorlayout);
      dialog.setTitle("Choose a Drawing Color");
  
      Button btnWH = (Button) dialog.findViewById(R.id.btnWhite);
      Button btnBL = (Button) dialog.findViewById(R.id.btnBlack);
      Button btnBLU = (Button) dialog.findViewById(R.id.btnBlue);
      Button btnCY = (Button) dialog.findViewById(R.id.btnCyan);
      Button btnDG = (Button) dialog.findViewById(R.id.btnDkGray);
      Button btnGR = (Button) dialog.findViewById(R.id.btnGray);
      Button btnGRE = (Button) dialog.findViewById(R.id.btnGreen);
      Button btnLG = (Button) dialog.findViewById(R.id.btnLtGray);
      Button btnMG = (Button) dialog.findViewById(R.id.btnMagenta);
      Button btnRD = (Button) dialog.findViewById(R.id.btnRed);
      Button btnYE = (Button) dialog.findViewById(R.id.btnYellow);
  
      if (btnWH != null) {
          btnWH.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.WHITE);
                  dialog.dismiss();
              }
          });
      }
      if (btnBL != null) {
          btnBL.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.BLACK);
                  dialog.dismiss();
              }
          });
      }
      if (btnBLU != null) {
          btnBLU.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.BLUE);
                  dialog.dismiss();
              }
          });
      }
      if (btnCY != null) {
          btnCY.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.CYAN);
                  dialog.dismiss();
              }
          });
      }
      if (btnDG != null) {
          btnDG.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.DKGRAY);
                  dialog.dismiss();
              }
          });
      }
      if (btnGR != null) {
          btnGR.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.GRAY);
                  dialog.dismiss();
              }
          });
      }
      if (btnGRE != null) {
          btnGRE.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.GREEN);
                  dialog.dismiss();
              }
          });
      }
      if (btnLG != null) {
          btnLG.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.LTGRAY);
                  dialog.dismiss();
              }
          });
      }
      if (btnMG != null) {
          btnMG.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.MAGENTA);
                  dialog.dismiss();
              }
          });
      }
      if (btnRD != null) {
          btnRD.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.RED);
                  dialog.dismiss();
              }
          });
      }
      if (btnYE != null) {
          btnYE.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  view.paint.setColor(Color.YELLOW);
                  dialog.dismiss();
              }
          });
      }
      dialog.show();
  }
  </code></pre>
  
  <p>Everything is working fine except everytime I choose a new color, anything that was drawn previously also changes to the newly chosen color. How do I keep whatever was drawn previously unchanged no matter what new color is chosen next?</p>