onDraw无法正常工作。它只显示一秒然后消失

时间:2015-08-05 14:33:10

标签: android draw surfaceview

我遇到绘图问题。它只显示它应该绘制一秒钟的元素然后再次为空。我在android表面视图中绘图。这是代码:

private void drawSurface(Canvas canvas) {
   canvas.drawColor(Color.YELLOW);
   for (int i = 0; i < points.size(); ++i) {

    System.out.println(i);
    point2 = points.get(i);
    canvas.drawCircle(point2.x, point2.y, RADIUS, paint);
    canvas.drawText(characters.get(i), point2.x, point2.y, tpaint);

}}

以下是我称之为此方法的地方:

 public void surfaceCreated(SurfaceHolder holder) {
    // TODO Auto-generated method stub
    addPoints();
    Canvas canvas = null;
    canvas = surfaceHolder.lockCanvas();
    if (null != canvas) {
        System.out.println("Created");
        drawSurface(canvas);
        surfaceHolder.unlockCanvasAndPost(canvas);
    }


}

0 个答案:

没有答案