title: Android - Changing colours in override methods
body: <p>I'm making a drawing app. I have two brushes <code>(img_brush and img_brush2)</code>. The initial colour is set to black in <code>PaintView()</code> <code>(on the line 'this.colour = Color.BLACK;')</code>. What I want to do is set different colours for both brushes in the override '<code>(onClick</code>) methods, for example blue for <code>img_brush</code> and red for <code>img_brush2</code>, how can I do it? This is the code I have got:</p>
  
  <pre><code>public class Draw_Activity extends Activity {
  
  private PaintView pv;
  protected View layout;
  protected int progress;
  protected Dialog dialog;
  protected Dialog textdialog;
  private String[] arrImagesStrings;
  protected float stroke = 6;
  int postion;
  private String fileName;
  private int ColorAh = Color.BLACK;
  String Foldername;
  RelativeLayout re;
  private AdView mAdView;
  ImageView img_brush, img_brush2;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.drawpic_activity);
  
      mAdView = (AdView) findViewById(R.id.adView);
      mAdView.loadAd(new AdRequest.Builder().build());
  
      re = (RelativeLayout) findViewById(R.id.rell);
      img_brush = (ImageView) findViewById(R.id.image_brush);
      img_brush2 = (ImageView) findViewById(R.id.image_brush2);
  
      this.fileName = null;
      super.onCreate(savedInstanceState);
      this.pv = new PaintView(this);
      re.addView(pv);
      //setContentView(this.pv);
      this.pv.togglePencil(true);
      Intent i = getIntent();
      Foldername = i.getStringExtra("Folder");
  
  
      img_brush.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Draw_Activity.this.pv.togglePencil(true);
          }
      });
  
      img_brush2.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Draw_Activity.this.pv.togglePencil(true);
          }
      });
  }
  
  //for color
  
  private void showColorPickerDialogDemo() {
  
      int initialColor = Color.WHITE;
  
      ColorPickerDialog colorPickerDialog = new ColorPickerDialog(Draw_Activity.this, initialColor, new OnColorSelectedListener() {
  
          public void onColorSelected(int color) {
  
              Draw_Activity.this.pv.setColor(color);
          }
  
      });
      colorPickerDialog.show();
  }
  
  private PaintView(Context c) {
      super(c);
  
      setDrawingCacheEnabled(true); // to save images
  
      this.context = c;
      this.colour = Color.BLACK;
  
      this.path = new Path();
      this.bmpPaint = new Paint();
      this.paint = new Paint();
      this.paint.setAntiAlias(true);
      this.paint.setDither(true);
      this.paint.setColor(this.colour);
      this.paint.setStyle(Paint.Style.STROKE);
      this.paint.setStrokeJoin(Paint.Join.ROUND);
      this.paint.setStrokeCap(Paint.Cap.ROUND);
      this.paint.setStrokeWidth(50);
  
      this._paintBlur = new Paint();
      this._paintBlur.set(paint);
      this._paintBlur.setAntiAlias(true);
      this._paintBlur.setDither(true);
      this._paintBlur.setStyle(Paint.Style.STROKE);
      this._paintBlur.setStrokeJoin(Paint.Join.ROUND);
      this._paintBlur.setStrokeCap(Paint.Cap.ROUND);
      this._paintBlur.setColor(Color.parseColor("#FA2B2B"));
      this._paintBlur.setStrokeWidth(6.0F);
      this._paintBlur.setMaskFilter(new BlurMaskFilter(10.0F, BlurMaskFilter.Blur.OUTER));
  
      this.bitmapforground = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  
      this.bitmapforground = BitmapFactory.decodeResource(getResources(),
              R.color.textbg);
  
  
  }
  
  public void setColor(int c) {
      this.paint.setColor(c);
      this.colour = c;
  }
  
  protected int getColor() {
      return this.colour;
  }
  }
  </code></pre>