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
Post a Comment