java - Android Canvas from external class will not show in Fragment -


im making android app, , have created class canvas in draw rectangle. want call class (its fragement) , show rectangle. here have:

this rectshape class:

public class rectshape extends view{  public rectshape(context context) {     super(context);     // todo auto-generated constructor stub }  @override protected void ondraw(canvas canvas) {      super.ondraw(canvas);      rect ourrect = new rect();     ourrect.set(3, 0, canvas.getwidth() - 3, 150);      paint postcolor = new paint();     postcolor.setcolor(color.white);     postcolor.setstyle(paint.style.fill);      canvas.drawrect(ourrect, postcolor);     } } 

this fragment class:

public class fragmentfeed extends fragment{  @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {      view v = inflater.inflate(r.layout.fragment_feed_layout, container, false);        rectshape shape = new rectshape(getactivity());        return v;      } } 

im not getting errors.. shape not showing up.. there wrong it? dont want call shape within same class.

you have add rectshape shape = new rectshape(getactivity()); fragment. initialising it. add view fragament , display.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -