Android 为什么我的球没有显示颜色?

Android 为什么我的球没有显示颜色?,android,android-canvas,Android,Android Canvas,在我的项目中,我给球添加了颜色,但它没有显示出来。为什么? 我只发布了对我的问题有意义的部分代码…setColor()方法是否有问题或其他问题…提前感谢您的帮助 AnimationView.java public class AnimationView extends View{ public AnimationView(Context context, AttributeSet attrs) { super(context, attrs);

在我的项目中,我给球添加了颜色,但它没有显示出来。为什么? 我只发布了对我的问题有意义的部分代码…setColor()方法是否有问题或其他问题…提前感谢您的帮助

AnimationView.java

public class AnimationView extends View{
      public AnimationView(Context context, AttributeSet attrs) {
            super(context, attrs);
            // TODO Auto-generated constructor stub
        }
    private final int FRAME_RATE=15;
      private Paint paint;
          private Handler h;
          Ball myball;

        int value;
        public void setString(int value)
        {
       this.value = value;
       System.out.println("value="+value);
       Animation();
    }
        public void Animation()
         { 
             h=new Handler();
                paint=new Paint();
                paint.setColor(Color.BLUE);
        myball=new Ball(100,100,Color.BLUE,50);
                    myball.setDX(10);
                    myball.setDY(10);
                    myball.setColor(Color.BLUE);
        }


        }
protected void onDraw(Canvas c)
    {

c.drawCircle(myball.getX(), myball.getY(),myball.getRadius(), myball.getPaint());
h.postDelayed(r, FRAME_RATE);

    }
    private Runnable r=new Runnable()
    { public void run()
    { invalidate();
    }
    };
Ball.java

 public class Ball {

private Point p;
private int c;
private int r;
private int dx;
private int dy;
private Paint paint;
public static int count = 0;
public Ball(int x,int y,int col,int radius)
{
    p=new Point(x,y);
    c=col;
    r=radius;
    paint=new Paint();
    dx=0;
    dy=0;
}

public Paint getPaint()
{return paint;
}
public void setColor(int col)
{c=col;
}
}

drawCircle
Paint
对象获取颜色。通过以下方式更改
setColor

public void setColor(int col) {
   c=col;
   if (paint == null) 
      paint = new Paint();
   paint.setColor(col);
}

drawCircle
Paint
对象获取颜色。通过以下方式更改
setColor

public void setColor(int col) {
   c=col;
   if (paint == null) 
      paint = new Paint();
   paint.setColor(col);
}

drawCircle
Paint
对象获取颜色。通过以下方式更改
setColor

public void setColor(int col) {
   c=col;
   if (paint == null) 
      paint = new Paint();
   paint.setColor(col);
}

drawCircle
Paint
对象获取颜色。通过以下方式更改
setColor

public void setColor(int col) {
   c=col;
   if (paint == null) 
      paint = new Paint();
   paint.setColor(col);
}