invalidate()
不記得我的OnDraw()
方法。我在setter方法在同一類OnDraw()
在使用invalidate()
。invalidate()不記得OnDraw方法
public class PuzzleDraw extends View {
// defining some variables //
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// codes for painting puzzle //
}
public PuzzleDraw(Context context) {
super(context);
}
// Method for giving cursor X/Y from MainActivity OnTouch() method and using it in OnDraw() method in some part of painting code //
public void setCursor(int i, int j) {
this.xx = i;
this.yy = j;
invalidate();
}
當我調試我的代碼,一切都只是憶及OnDraw()
invalidate()
執行時......其實 好,invalidate()
是什麼都不做我! 有什麼不對? 我也使用postInvalidate()
,this.invalidate()
, this.postInvalidate()
,但沒有任何變化。
那麼我該怎麼辦?我需要我的OnDraw()在每次執行OnTouch()事件時執行......我需要它。 – androidprogrammer2012 2012-07-30 11:29:43
如果你已經調用了'invalidate',你的'onDraw'方法肯定會以系統可用來繪製視圖的速度執行。如果你想更好地控制繪製過程,你應該考慮使用'SurfaceView'。 – 2012-07-30 11:40:41
問題不是關於快速還是緩慢!問題是我的OnDraw()方法在invalidate()調用時不工作。 (不「工作緩慢」,只是不工作) – androidprogrammer2012 2012-07-30 11:53:20