java - Android - Changing colours in override methods -


i'm making drawing app. have 2 brushes (img_brush , img_brush2). initial colour set black in paintview() (on line 'this.colour = color.black;'). want set different colours both brushes in override '(onclick) methods, example blue img_brush , red img_brush2, how can it? code have got:

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 = 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); // 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; } } 


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -