0
   @Override
protected void onDraw(Canvas canvas){  
                super.onDraw(canvas);
                Paint paint = new Paint();
                canvas.drawPaint(paint);
                paint.setStyle(Paint.Style.FILL);
                paint.setColor(Color.WHITE);
                update();
                canvas.drawCircle(XC, YC, radius, paint);
                }

SurfaceView 中的 render 方法第一次最小化程序 - 展开时一切正常。当重折叠是错误时

04-29 22:57:16.959: E/AndroidRuntime(4813): FATAL EXCEPTION: Thread-23150

04-29 22:57:16.959: E/AndroidRuntime(4813): java.lang.NullPointerException

04-29 22:57:16.959: E/AndroidRuntime(4813): at com.example.blindballtest.GameField.onDraw(GameField.java:10 1)

04-29 22:57:16.959: E/AndroidRuntime(4813): at com.example.blindballtest.ThreadGame.run(ThreadGame.java:42)

请告诉我,出了什么问题以及如何解决?

对不起我的英语不好。

4

1 回答 1

0

试试这个代码...

  @Override
 protected void onDraw(Canvas canvas){  
            this.oDraw(canvas);

            }
private void oDraw(Canvas canvas){
Paint paint = new Paint();
            canvas.drawPaint(paint);
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(Color.WHITE);
            update();
            canvas.drawCircle(XC, YC, radius, paint);
}
于 2013-04-29T20:13:41.317 回答