java - onDraw Method not Called? -


i creating custom view ondraw method never being called. tried doing - setwillnotdraw(false) still doesn't work.

in fact, doesn't work after calling invalidate(). here's code -

public class box extends view {     public box (context context) {         super (context);         init();     }      private void init() {    // initialize paint object         paint = new paint();         paint.setstyle(paint.style.fill);         paint.setcolor(mboxcolor);         setmeasureddimension(200, 200);     }      @override     protected void ondraw(canvas canvas) {         super.ondraw(canvas);         canvas.drawrect(100, 100, 200, 200, paint);     } } 

my activity code -

box box = new box(this); 

please help

in mainactivity.java

use

setcontentview(box); 

Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -