-1
我想绘制一个矩形,但如果我运行它,我会得到一个错误。 LogFile说:不能instanciate类[...]没有空的构造函数。但为什么?android - onDraw()方法
public class MainActivity extends View {
public MainActivity(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Rect ourRect = new Rect();
ourRect.set(0, 0, canvas.getWidth(), canvas.getHeight()/2);
Paint blue = new Paint();
blue.setColor(Color.BLUE);
blue.setStyle(Paint.Style.FILL);
canvas.drawRect(ourRect, blue);
}
}
的[无法实例类可能的复制......;没有空的构造函数](http://stackoverflow.com/questions/24893608/cant-instantiate-class-no-empty-constructor) – maszter