@Override
protected void onDraw(Canvas canvas)
{
//Note:I do not want to use the canvas object from this function param
//If i do so its working , But i would like to understand why the following is not working
Canvas c =new Canvas();
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
paint.setColor(Color.WHITE);
c.drawText("HELLO CANVAS",200,300,paint);
}
MORE CODE
public class graphicProj extends Activity {
private Canvas canvas;
@Override
public void onCreate(Bundle savedInstanceState) {
{
....
SimpleView simpleview_obj = new SimpleView(this);
setContentView(simpleview_obj);
simpleview_obj.onDraw(canvas);
.....
new GetData().execute();
}
private static class SimpleView extends View {
private ShapeDrawable mDrawable = new ShapeDrawable();
....
protected void onDraw(Canvas canvas) {
//draw graphic objects
....
}
}
public class GetData extends AsyncTask<Void, String, Void> {
@Override
protected void onPreExecute() {
Log.d("PROJ","STARTIN");
}
@Override
protected Void doInBackground(Void... unused) {
////My calculation and reading frm DataStream
}
@Override
protected void onProgressUpdate(String... data) {
//I Keep updating the result...
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
paint.setColor(Color.WHITE);
canvas.drawText(result, 200, 300, paint);
}
@Override
protected void onPostExecute(Void unused) {
Log.d("PROJ","END");
}
}
}