class DrawThread extends Thread {
private boolean Flag = false;
private SurfaceHolder surfaceHolder;
public DrawThread(SurfaceHolder surfaceHolder, Resources resources) {
this.surfaceHolder = surfaceHolder;
}
public void setRunning(boolean run) {
Flag = run;
}
static boolean Flag2 = true;
Canvas canvas;
Paint paint = new Paint();
static int xx = 20;
static int yy = 20;
public void run() {
while (Flag) {
canvas = null;
try {
canvas = surfaceHolder.lockCanvas(null);
synchronized (surfaceHolder) {
paint.setColor(Color.WHITE);
canvas.drawPaint(paint);
paint.setColor(Color.GREEN);
if (Flag2) {
canvas.drawCircle(xx, yy, 20, paint);
}
}
} finally {
if (canvas != null) {
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
}
}
Что интересно, отрисовка по начальным координатам (заданы в объявлении переменных) происходит верно.