-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