android 图形不工作

android graphics not working

这是一个非常基本的代码,应该画一个圆,但应用程序不工作,但只要我删除画圆的线,它就会开始正常工作

public class MainActivity extends ActionBarActivity implements  
OnTouchListener {

SVclass SV1;
int screenW, screenH;
Canvas canvas;
float x=0;
float y=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SV1=new SVclass(this);
    SV1.setOnTouchListener(this);
    setContentView(SV1);
}

public class SVclass extends SurfaceView implements Runnable {

    boolean isitOk=true;
    SurfaceHolder holder;
    Thread t=null;

    public SVclass(Context context) {
        super(context);
        holder=getHolder();
    }

    @Override
    public void onSizeChanged(int w,int h, int oldw, int oldh){
        super.onSizeChanged(w, h, oldw, oldh);
        screenW=w;
        screenH=h;
    }

    @Override
    public void run() {
        while(isitOk=true){
            if(!holder.getSurface().isValid()){
                continue;
            }
            canvas=holder.lockCanvas();
            canvas.drawARGB(255, 150, 150, 150);
            canvas.drawCircle(100, 100, 10, null);
            holder.unlockCanvasAndPost(canvas);
        }   
    }

    public void pause(){
        isitOk=false;
        while(true){
            try{
                t.join();
            }catch(InterruptedException e){
                e.printStackTrace();
            }
            break;
        }
        t=null;
    }

    public void resume(){
        isitOk=true;
        t=new Thread(this);
        t.start();
    }

}

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch(event.getAction()){
    case MotionEvent.ACTION_DOWN:

        break;
    case MotionEvent.ACTION_UP:
        break;
    case MotionEvent.ACTION_MOVE:
        x=event.getX();
        y=event.getY();
        break;
    }
    return true;
}

public void onPause(){
    super.onPause();
    SV1.pause();
}

public void onResume(){
    super.onResume();
    SV1.resume();
}

}

这是我的 Logcat

02-01 09:18:25.472: E/ResourceType(2373): Style contains key with bad entry:     
0x01010479
02-01 09:18:25.484: I/dalvikvm(2373): Could not find method 
android.view.ViewGroup.onNestedScrollAccepted, referenced from method     
android.support.v7.internal.widget.ActionBarOverlayLayout. 
onNestedScrollAccepted
02-01 09:18:25.484: W/dalvikvm(2373): VFY: unable to resolve virtual method     
11351: Landroid/view/ViewGroup;.onNestedScrollAccepted 
(Landroid/view/View;Landroid/view/View;I)V
02-01 09:18:25.484: D/dalvikvm(2373): VFY: replacing opcode 0x6f at 0x0000
02-01 09:18:25.484: I/dalvikvm(2373): Could not find method     
android.view.ViewGroup.onStopNestedScroll, referenced from method     
android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
02-01 09:18:25.484: W/dalvikvm(2373): VFY: unable to resolve virtual method 
11357: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
02-01 09:18:25.484: D/dalvikvm(2373): VFY: replacing opcode 0x6f at 0x0000
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method 
android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll,     
referenced from method     
android.support.v7.internal.widget.ActionBarOverlayLayout.     
setHideOnContentScrollEnabled
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method     
9039:     
Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll     
()V
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x000e
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method     
android.content.res.TypedArray.getChangingConfigurations, referenced from     
method 
android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method     
364: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x0002
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method 
android.content.res.TypedArray.getType, referenced from method 
android.support.v7.internal.widget.TintTypedArray.getType
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method 
386: Landroid/content/res/TypedArray;.getType (I)I
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x0002
02-01 09:18:25.552: D/libEGL(2373): loaded 
/system/lib/egl/libEGL_genymotion.so
02-01 09:18:25.552: D/(2373): HostConnection::get() New Host Connection 
established 0xb7a4a320, tid 2373
02-01 09:18:25.568: D/libEGL(2373): loaded     
/system/lib/egl/libGLESv1_CM_genymotion.so
02-01 09:18:25.568: D/libEGL(2373): loaded 
/system/lib/egl/libGLESv2_genymotion.so
02-01 09:18:25.620: W/EGL_genymotion(2373): eglSurfaceAttrib not implemented
02-01 09:18:25.644: D/OpenGLRenderer(2373): Enabling debug mode 0
02-01 09:18:25.684: D/(2373): HostConnection::get() New Host Connection 
established 0xb7ab7ba0, tid 2385
02-01 09:18:25.708: W/dalvikvm(2373): threadid=10: thread exiting with 
uncaught exception (group=0xa612e908)
02-01 09:18:25.708: E/AndroidRuntime(2373): FATAL EXCEPTION: Thread-167
02-01 09:18:25.708: E/AndroidRuntime(2373): java.lang.NullPointerException
02-01 09:18:25.708: E/AndroidRuntime(2373):     at 
android.graphics.Canvas.drawCircle(Canvas.java:961)
02-01 09:18:25.708: E/AndroidRuntime(2373):     at 
com.sanillk.game2.MainActivity$SVclass.run(MainActivity.java:58)
02-01 09:18:25.708: E/AndroidRuntime(2373):     at     
java.lang.Thread.run(Thread.java:856)

我已经尝试了很多,但我无法找出问题所在,谁能帮帮我?

尝试向 drawCircle 函数添加一个 Paint 变量 即 canvas.drawCircle(100, 100, 10, new Paint());