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

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -